public final class RelTraitSet extends AbstractList<RelTrait>
RelTraits.modCount| Modifier and Type | Method and Description |
|---|---|
boolean |
allSimple()
Returns whether there are any composite traits in this set.
|
<T extends RelTrait> |
canonize(T trait)
Converts a trait to canonical form.
|
boolean |
comprises(RelTrait... relTraits)
Returns whether this trait set comprises precisely the list of given
traits.
|
protected String |
computeString()
Outputs the traits of this set as a String.
|
boolean |
contains(RelTrait trait)
Returns whether this trait set contains a given trait.
|
boolean |
containsIfApplicable(RelTrait trait)
Returns whether this trait set contains the given trait, or whether the
trait is not present because its
RelTraitDef is not enabled. |
static RelTraitSet |
createEmpty()
Creates an empty trait set.
|
com.google.common.collect.ImmutableList<RelTrait> |
difference(RelTraitSet traitSet)
Returns a list of traits that are in
traitSet but not in this
RelTraitSet. |
boolean |
equals(Object obj)
Compares two RelTraitSet objects for equality.
|
RelTrait |
get(int index) |
RelTrait |
getTrait(int index)
Retrieves a RelTrait from the set.
|
<T extends RelTrait> |
getTrait(RelTraitDef<T> traitDef)
Retrieves a RelTrait of the given type from the set.
|
<E extends RelMultipleTrait> |
getTraits(int index)
Retrieves a list of traits from the set.
|
<T extends RelMultipleTrait> |
getTraits(RelTraitDef<T> traitDef)
Retrieves a list of traits of the given type from the set.
|
int |
hashCode() |
<T extends RelTrait> |
isEnabled(RelTraitDef<T> traitDef)
Returns whether a given kind of trait is enabled.
|
boolean |
matches(RelTraitSet that)
Compares two RelTraitSet objects to see if they match for the purposes of
firing a rule.
|
RelTraitSet |
merge(RelTraitSet additionalTraits) |
RelTraitSet |
plus(RelTrait trait)
Returns this trait set with a given trait added or overridden.
|
RelTraitSet |
plusAll(RelTrait[] traits) |
RelTraitSet |
replace(int index,
RelTrait trait)
Replaces an existing RelTrait in the set.
|
<T extends RelMultipleTrait> |
replace(List<T> traits)
Replaces the trait(s) of a given type with a list of traits of the same
type.
|
RelTraitSet |
replace(RelTrait trait)
Returns a trait set consisting of the current set plus a new trait.
|
<T extends RelMultipleTrait> |
replace(RelTraitDef<T> def,
List<T> traits)
Replaces the trait(s) of a given type with a list of traits of the same
type.
|
<T extends RelTrait> |
replaceIf(RelTraitDef<T> def,
com.google.common.base.Supplier<T> traitSupplier)
If a given trait is enabled, replaces it by calling the given function.
|
<T extends RelMultipleTrait> |
replaceIfs(RelTraitDef<T> def,
com.google.common.base.Supplier<List<T>> traitSupplier)
If a given multiple trait is enabled, replaces it by calling the given
function.
|
boolean |
satisfies(RelTraitSet that)
Returns whether this trait set satisfies another trait set.
|
RelTraitSet |
simplify()
Returns a trait set similar to this one but with all composite traits
flattened.
|
int |
size()
Returns the size of the RelTraitSet.
|
String |
toString() |
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArraypublic static RelTraitSet createEmpty()
It has a new cache, which will be shared by any trait set created from it. Thus each empty trait set is the start of a new ancestral line.
public RelTrait getTrait(int index)
index - 0-based index into ordered RelTraitSetArrayIndexOutOfBoundsException - if index greater than or equal to
size() or less than 0.public <E extends RelMultipleTrait> List<E> getTraits(int index)
index - 0-based index into ordered RelTraitSetArrayIndexOutOfBoundsException - if index greater than or equal to
size() or less than 0.public RelTrait get(int index)
public <T extends RelTrait> boolean isEnabled(RelTraitDef<T> traitDef)
public <T extends RelTrait> T getTrait(RelTraitDef<T> traitDef)
traitDef - the type of RelTrait to retrievepublic <T extends RelMultipleTrait> List<T> getTraits(RelTraitDef<T> traitDef)
Only valid for traits that support multiple entries. (E.g. collation.)
traitDef - the type of RelTrait to retrievepublic RelTraitSet replace(int index, RelTrait trait)
index - 0-based index into ordered RelTraitSettrait - the new RelTraitpublic RelTraitSet replace(RelTrait trait)
If the set does not contain a trait of the same RelTraitDef,
the trait is ignored, and this trait set is returned.
trait - the new traitplus(RelTrait)public <T extends RelMultipleTrait> RelTraitSet replace(List<T> traits)
The list must not be empty, and all traits must be of the same type.
public <T extends RelMultipleTrait> RelTraitSet replace(RelTraitDef<T> def, List<T> traits)
The list must not be empty, and all traits must be of the same type.
public <T extends RelMultipleTrait> RelTraitSet replaceIfs(RelTraitDef<T> def, com.google.common.base.Supplier<List<T>> traitSupplier)
public <T extends RelTrait> RelTraitSet replaceIf(RelTraitDef<T> def, com.google.common.base.Supplier<T> traitSupplier)
public int size()
size in interface Collection<RelTrait>size in interface List<RelTrait>size in class AbstractCollection<RelTrait>public <T extends RelTrait> T canonize(T trait)
After canonization, t1.equals(t2) if and only if t1 == t2.
trait - Traitpublic boolean equals(Object obj)
equals in interface Collection<RelTrait>equals in interface List<RelTrait>equals in class AbstractList<RelTrait>obj - another RelTraitSetpublic int hashCode()
hashCode in interface Collection<RelTrait>hashCode in interface List<RelTrait>hashCode in class AbstractList<RelTrait>public boolean satisfies(RelTraitSet that)
For that to happen, each trait satisfies the corresponding trait in the other set. In particular, each trait set satisfies itself, because each trait subsumes itself.
Intuitively, if a relational expression is needed that has trait set S (A, B), and trait set S1 (A1, B1) subsumes S, then any relational expression R in S1 meets that need.
For example, if we need a relational expression that has trait set S = {enumerable convention, sorted on [C1 asc]}, and R has {enumerable convention, sorted on [C3], [C1, C2]}. R has two sort keys, but one them [C1, C2] satisfies S [C1], and that is enough.
that - another RelTraitSetRelTrait.satisfies(RelTrait)public boolean matches(RelTraitSet that)
that - another RelTraitSetpublic boolean contains(RelTrait trait)
trait - Sought traitpublic boolean containsIfApplicable(RelTrait trait)
RelTraitDef is not enabled.
Returns false if another trait of the same RelTraitDef is
present.trait - Traitpublic boolean comprises(RelTrait... relTraits)
relTraits - Traitspublic String toString()
toString in class AbstractCollection<RelTrait>protected String computeString()
public RelTraitSet plus(RelTrait trait)
trait - Traitpublic RelTraitSet plusAll(RelTrait[] traits)
public RelTraitSet merge(RelTraitSet additionalTraits)
public com.google.common.collect.ImmutableList<RelTrait> difference(RelTraitSet traitSet)
traitSet but not in this
RelTraitSet.public boolean allSimple()
public RelTraitSet simplify()
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.