001/* 002 * Copyright 2018 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.cms.search.advanced; 017 018import java.util.List; 019 020import org.ametys.cms.search.query.Query.LogicalOperator; 021 022/** 023 * This class represents an internal node in a tree data structure, which have {@link AbstractTreeNode} {@link #getChildren children} (at least 1), 024 * linked by a {@link #getLogicalOperator() logical operator}. 025 * @param <T> the type of the values of the leaves of the tree. 026 */ 027public final class TreeInternalNode<T> extends AbstractTreeNode<T> 028{ 029 private List<AbstractTreeNode<T>> _children; 030 private LogicalOperator _operator; 031 032 /** 033 * Constructs a new internal node in a tree data structure with the given children 034 * and the given logical operator to link these children. 035 * @param children the children of the internal node 036 * @param operator the logical operator to link the children 037 */ 038 public TreeInternalNode(List<AbstractTreeNode<T>> children, LogicalOperator operator) 039 { 040 if (children.size() < 1) 041 { 042 throw new IllegalArgumentException("There must be at least one child."); 043 } 044 _children = children; 045 _operator = operator; 046 } 047 048 /** 049 * Gets the children 050 * @return the children 051 */ 052 public List<AbstractTreeNode<T>> getChildren() 053 { 054 return _children; 055 } 056 057 /** 058 * Gets the logical operator 059 * @return the logical operator 060 */ 061 public LogicalOperator getLogicalOperator() 062 { 063 return _operator; 064 } 065} 066