Class RelTraitSet
RelTraits.-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether there are any composite traits in this set.apply(Mappings.TargetMapping mapping) Applies a mapping to this traitSet.<T extends RelTrait>
Tcanonize(T trait) Converts a trait to canonical form.booleanReturns whether this trait set comprises precisely the list of given traits.booleanReturns whether this trait set contains a given trait.booleancontainsIfApplicable(RelTrait trait) Returns whether this trait set contains the given trait, or whether the trait is not present because itsRelTraitDefis not enabled.static RelTraitSetCreates an empty trait set.com.google.common.collect.ImmutableList<RelTrait>difference(RelTraitSet traitSet) Returns a list of traits that are intraitSetbut not in this RelTraitSet.booleanCompares two RelTraitSet objects for equality.booleanequalsSansConvention(RelTraitSet other) Returns whether all the traits exceptConventionequals with traits inothertraitSet.get(int index) <T extends RelCollation>
@Nullable TReturnsRelCollationtrait defined byRelCollationTraitDef.INSTANCE, or null if theRelCollationTraitDef.INSTANCEis not registered in this traitSet.@Nullable ConventionReturnsConventiontrait defined byConventionTraitDef.INSTANCE, or null if theConventionTraitDef.INSTANCEis not registered in this traitSet.Returns a new traitSet with same traitDefs with current traitSet, but each trait is the default trait value.Returns a new traitSet with same traitDefs with current traitSet, but each trait exceptConventionis the default trait value.<T extends RelDistribution>
@Nullable TReturnsRelDistributiontrait defined byRelDistributionTraitDef.INSTANCE, or null if theRelDistributionTraitDef.INSTANCEis not registered in this traitSet.getTrait(int index) Retrieves a RelTrait from the set.<T extends RelTrait>
@Nullable TgetTrait(RelTraitDef<T> traitDef) Retrieves a RelTrait of the given type from the set.<E extends RelMultipleTrait>
List<E>getTraits(int index) Retrieves a list of traits from the set.<T extends RelMultipleTrait>
@Nullable List<T>getTraits(RelTraitDef<T> traitDef) Retrieves a list of traits of the given type from the set.inthashCode()booleanReturns whether all the traits are default trait value.booleanReturns whether all the traits exceptConventionare default trait value.<T extends RelTrait>
booleanisEnabled(RelTraitDef<T> traitDef) Returns whether a given kind of trait is enabled.booleanmatches(RelTraitSet that) Compares two RelTraitSet objects to see if they match for the purposes of firing a rule.merge(RelTraitSet additionalTraits) Returns this trait set with a given trait added or overridden.Replaces an existing RelTrait in the set.<T extends RelMultipleTrait>
RelTraitSetReplaces the trait(s) of a given type with a list of traits of the same type.Returns a trait set consisting of the current set plus a new trait.<T extends RelMultipleTrait>
RelTraitSetreplace(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>
RelTraitSetreplaceIf(RelTraitDef<T> def, Supplier<? extends @Nullable T> traitSupplier) If a given trait is enabled, replaces it by calling the given function.<T extends RelMultipleTrait>
RelTraitSetreplaceIfs(RelTraitDef<T> def, Supplier<? extends @Nullable List<T>> traitSupplier) If a given multiple trait is enabled, replaces it by calling the given function.booleansatisfies(RelTraitSet that) Returns whether this trait set satisfies another trait set.simplify()Returns a trait set similar to this one but with all composite traits flattened.intsize()Returns the size of the RelTraitSet.toString()Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Method Details
-
createEmpty
Creates an empty trait set.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.
-
getTrait
Retrieves a RelTrait from the set.- Parameters:
index- 0-based index into ordered RelTraitSet- Returns:
- the RelTrait
- Throws:
ArrayIndexOutOfBoundsException- if index greater than or equal tosize()or less than 0.
-
getTraits
Retrieves a list of traits from the set.- Parameters:
index- 0-based index into ordered RelTraitSet- Returns:
- the RelTrait
- Throws:
ArrayIndexOutOfBoundsException- if index greater than or equal tosize()or less than 0.
-
get
-
isEnabled
Returns whether a given kind of trait is enabled. -
getTrait
Retrieves a RelTrait of the given type from the set.- Parameters:
traitDef- the type of RelTrait to retrieve- Returns:
- the RelTrait, or null if not found
-
getTraits
Retrieves a list of traits of the given type from the set.Only valid for traits that support multiple entries. (E.g. collation.)
- Parameters:
traitDef- the type of RelTrait to retrieve- Returns:
- the RelTrait, or null if not found
-
replace
Replaces an existing RelTrait in the set. Returns a different trait set; does not modify this trait set.- Parameters:
index- 0-based index into ordered RelTraitSettrait- the new RelTrait- Returns:
- the old RelTrait at the index
-
replace
Returns a trait set consisting of the current set plus a new trait.If the set does not contain a trait of the same
RelTraitDef, the trait is ignored, and this trait set is returned.- Parameters:
trait- the new trait- Returns:
- New set
- See Also:
-
replace
Replaces the trait(s) of a given type with a list of traits of the same type.The list must not be empty, and all traits must be of the same type.
-
replace
Replaces the trait(s) of a given type with a list of traits of the same type.The list must not be empty, and all traits must be of the same type.
-
replaceIfs
public <T extends RelMultipleTrait> RelTraitSet replaceIfs(RelTraitDef<T> def, Supplier<? extends @Nullable List<T>> traitSupplier) If a given multiple trait is enabled, replaces it by calling the given function. -
replaceIf
public <T extends RelTrait> RelTraitSet replaceIf(RelTraitDef<T> def, Supplier<? extends @Nullable T> traitSupplier) If a given trait is enabled, replaces it by calling the given function. -
apply
Applies a mapping to this traitSet.- Parameters:
mapping- Mapping- Returns:
- traitSet with mapping applied
-
isDefault
public boolean isDefault()Returns whether all the traits are default trait value. -
isDefaultSansConvention
public boolean isDefaultSansConvention()Returns whether all the traits exceptConventionare default trait value. -
equalsSansConvention
Returns whether all the traits exceptConventionequals with traits inothertraitSet. -
getDefault
Returns a new traitSet with same traitDefs with current traitSet, but each trait is the default trait value. -
getDefaultSansConvention
Returns a new traitSet with same traitDefs with current traitSet, but each trait exceptConventionis the default trait value.Conventiontrait remains the same with current traitSet. -
getConvention
ReturnsConventiontrait defined byConventionTraitDef.INSTANCE, or null if theConventionTraitDef.INSTANCEis not registered in this traitSet. -
getDistribution
ReturnsRelDistributiontrait defined byRelDistributionTraitDef.INSTANCE, or null if theRelDistributionTraitDef.INSTANCEis not registered in this traitSet. -
getCollation
ReturnsRelCollationtrait defined byRelCollationTraitDef.INSTANCE, or null if theRelCollationTraitDef.INSTANCEis not registered in this traitSet. -
size
public int size()Returns the size of the RelTraitSet.- Specified by:
sizein interfaceCollection<RelTrait>- Specified by:
sizein interfaceList<RelTrait>- Specified by:
sizein classAbstractCollection<RelTrait>- Returns:
- the size of the RelTraitSet.
-
canonize
Converts a trait to canonical form.After canonization, t1.equals(t2) if and only if t1 == t2.
- Parameters:
trait- Trait- Returns:
- Trait in canonical form
-
equals
Compares two RelTraitSet objects for equality.- Specified by:
equalsin interfaceCollection<RelTrait>- Specified by:
equalsin interfaceList<RelTrait>- Overrides:
equalsin classAbstractList<RelTrait>- Parameters:
obj- another RelTraitSet- Returns:
- true if traits are equal and in the same order, false otherwise
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<RelTrait>- Specified by:
hashCodein interfaceList<RelTrait>- Overrides:
hashCodein classAbstractList<RelTrait>
-
satisfies
Returns whether this trait set satisfies another trait set.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.
- Parameters:
that- another RelTraitSet- Returns:
- whether this trait set satisfies other trait set
- See Also:
-
matches
Compares two RelTraitSet objects to see if they match for the purposes of firing a rule. A null RelTrait within a RelTraitSet indicates a wildcard: any RelTrait in the other RelTraitSet will match. If one RelTraitSet is smaller than the other, comparison stops when the last RelTrait from the smaller set has been examined and the remaining RelTraits in the larger set are assumed to match.- Parameters:
that- another RelTraitSet- Returns:
- true if the RelTraitSets match, false otherwise
-
contains
Returns whether this trait set contains a given trait.- Parameters:
trait- Sought trait- Returns:
- Whether set contains given trait
-
containsIfApplicable
Returns whether this trait set contains the given trait, or whether the trait is not present because itsRelTraitDefis not enabled. Returns false if another trait of the sameRelTraitDefis present.- Parameters:
trait- Trait- Returns:
- Whether trait is present, or is absent because disabled
-
comprises
Returns whether this trait set comprises precisely the list of given traits.- Parameters:
relTraits- Traits- Returns:
- Whether this trait set's traits are the same as the argument
-
toString
- Overrides:
toStringin classAbstractCollection<RelTrait>
-
plus
Returns this trait set with a given trait added or overridden. Does not modify this trait set.- Parameters:
trait- Trait- Returns:
- Trait set with given trait
-
plusAll
-
merge
-
difference
Returns a list of traits that are intraitSetbut not in this RelTraitSet. -
allSimple
public boolean allSimple()Returns whether there are any composite traits in this set. -
simplify
Returns a trait set similar to this one but with all composite traits flattened.
-