Class RelTraitSet
RelTrait
s.-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns 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.boolean
Returns whether this trait set comprises precisely the list of given traits.boolean
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 itsRelTraitDef
is not enabled.static RelTraitSet
Creates an empty trait set.com.google.common.collect.ImmutableList<RelTrait>
difference
(RelTraitSet traitSet) Returns a list of traits that are intraitSet
but not in this RelTraitSet.boolean
Compares two RelTraitSet objects for equality.boolean
equalsSansConvention
(RelTraitSet other) Returns whether all the traits exceptConvention
equals with traits inother
traitSet.get
(int index) <T extends RelCollation>
@Nullable TReturnsRelCollation
trait defined byRelCollationTraitDef.INSTANCE
, or null if theRelCollationTraitDef.INSTANCE
is not registered in this traitSet.@Nullable Convention
ReturnsConvention
trait defined byConventionTraitDef.INSTANCE
, or null if theConventionTraitDef.INSTANCE
is 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 exceptConvention
is the default trait value.<T extends RelDistribution>
@Nullable TReturnsRelDistribution
trait defined byRelDistributionTraitDef.INSTANCE
, or null if theRelDistributionTraitDef.INSTANCE
is 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.int
hashCode()
boolean
Returns whether all the traits are default trait value.boolean
Returns whether all the traits exceptConvention
are default trait value.<T extends RelTrait>
booleanisEnabled
(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.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.boolean
satisfies
(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.int
size()
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, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods 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 exceptConvention
are default trait value. -
equalsSansConvention
Returns whether all the traits exceptConvention
equals with traits inother
traitSet. -
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 exceptConvention
is the default trait value.Convention
trait remains the same with current traitSet. -
getConvention
ReturnsConvention
trait defined byConventionTraitDef.INSTANCE
, or null if theConventionTraitDef.INSTANCE
is not registered in this traitSet. -
getDistribution
ReturnsRelDistribution
trait defined byRelDistributionTraitDef.INSTANCE
, or null if theRelDistributionTraitDef.INSTANCE
is not registered in this traitSet. -
getCollation
ReturnsRelCollation
trait defined byRelCollationTraitDef.INSTANCE
, or null if theRelCollationTraitDef.INSTANCE
is not registered in this traitSet. -
size
public int size()Returns the size of the RelTraitSet.- Specified by:
size
in interfaceCollection<RelTrait>
- Specified by:
size
in interfaceList<RelTrait>
- Specified by:
size
in 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:
equals
in interfaceCollection<RelTrait>
- Specified by:
equals
in interfaceList<RelTrait>
- Overrides:
equals
in 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:
hashCode
in interfaceCollection<RelTrait>
- Specified by:
hashCode
in interfaceList<RelTrait>
- Overrides:
hashCode
in 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 itsRelTraitDef
is not enabled. Returns false if another trait of the sameRelTraitDef
is 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:
toString
in 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 intraitSet
but 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.
-