View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors.
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   * 
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.graph.query.model;
25  
26  import java.util.Set;
27  import net.jcip.annotations.Immutable;
28  
29  /**
30   * A dynamic operand used in a {@link Comparison} constraint.
31   */
32  @Immutable
33  public interface DynamicOperand extends LanguageObject {
34      // private static final long serialVersionUID = 1L;
35      //
36      // private final Set<SelectorName> selectorNames;
37      //
38      // /**
39      // * Create a arithmetic dynamic operand that operates upon the supplied selector name(s).
40      // *
41      // * @param selectorNames the selector names
42      // * @throws IllegalArgumentException if the selector names array is null or empty, or if any of the values are null
43      // */
44      // protected DynamicOperand( SelectorName... selectorNames ) {
45      // CheckArg.isNotNull(selectorNames, "selectorNames");
46      // if (selectorNames.length == 1) {
47      // CheckArg.isNotNull(selectorNames, "selectorNames[0]");
48      // this.selectorNames = Collections.singleton(selectorNames[0]);
49      // } else {
50      // CheckArg.isNotNull(selectorNames, "selectorNames[0]");
51      // this.selectorNames = Collections.unmodifiableSet(new LinkedHashSet<SelectorName>(Arrays.asList(selectorNames)));
52      // int i = 0;
53      // for (SelectorName name : this.selectorNames) {
54      // CheckArg.isNotNull(name, "selectorNames[" + i++ + "]");
55      // }
56      // }
57      // }
58      //
59      // /**
60      // * Create a arithmetic dynamic operand that operates upon the supplied selector name(s).
61      // *
62      // * @param selectorNames the selector names
63      // * @throws IllegalArgumentException if the name list is null or empty, or if any of the values are null
64      // */
65      // protected DynamicOperand( Collection<SelectorName> selectorNames ) {
66      // CheckArg.isNotNull(selectorNames, "selectorName");
67      // this.selectorNames = Collections.unmodifiableSet(new LinkedHashSet<SelectorName>(selectorNames));
68      // }
69      //
70      // /**
71      // * Create a arithmetic dynamic operand that operates upon the selector names given by the supplied dynamic operand(s).
72      // *
73      // * @param operand the operand defining the selector names
74      // * @throws IllegalArgumentException if the operand is null
75      // */
76      // protected DynamicOperand( DynamicOperand operand ) {
77      // CheckArg.isNotNull(operand, "operand");
78      // this.selectorNames = operand.selectorNames(); // immutable, so we can reference it directly
79      // }
80      //
81      // /**
82      // * Create a arithmetic dynamic operand that operates upon the selector names given by the supplied dynamic operand(s).
83      // *
84      // * @param operands the operands defining the selector names
85      // * @throws IllegalArgumentException if the operand is null
86      // */
87      // protected DynamicOperand( Iterable<? extends DynamicOperand> operands ) {
88      // CheckArg.isNotNull(operands, "operands");
89      // Set<SelectorName> names = new LinkedHashSet<SelectorName>();
90      // for (DynamicOperand operand : operands) {
91      // names.addAll(operand.selectorNames());
92      // }
93      // this.selectorNames = Collections.unmodifiableSet(names);
94      // }
95      //
96      // /**
97      // * Create a arithmetic dynamic operand that operates upon the selector names given by the supplied dynamic operand(s).
98      // *
99      // * @param operands the operands defining the selector names
100     // * @throws IllegalArgumentException if the operand is null
101     // */
102     // protected DynamicOperand( DynamicOperand... operands ) {
103     // CheckArg.isNotNull(operands, "operands");
104     // Set<SelectorName> names = new LinkedHashSet<SelectorName>();
105     // for (DynamicOperand operand : operands) {
106     // names.addAll(operand.selectorNames());
107     // }
108     // this.selectorNames = Collections.unmodifiableSet(names);
109     // }
110 
111     /**
112      * Get the selector symbols to which this operand applies.
113      * 
114      * @return the immutable ordered set of non-null selector names used by this operand; never null and never empty
115      */
116     public Set<SelectorName> selectorNames();
117 }