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.
|
RelTraitSet |
apply(Mappings.TargetMapping mapping)
Applies a mapping to this traitSet.
|
<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.
|
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(@Nullable Object obj)
Compares two RelTraitSet objects for equality.
|
boolean |
equalsSansConvention(RelTraitSet other)
Returns whether all the traits except
Convention
equals with traits in other traitSet. |
RelTrait |
get(int index) |
<T extends RelCollation> |
getCollation()
Returns
RelCollation trait defined by
RelCollationTraitDef.INSTANCE, or null if the
RelCollationTraitDef.INSTANCE is not registered
in this traitSet. |
@Nullable Convention |
getConvention()
Returns
Convention trait defined by
ConventionTraitDef.INSTANCE, or null if the
ConventionTraitDef.INSTANCE is not registered
in this traitSet. |
RelTraitSet |
getDefault()
Returns a new traitSet with same traitDefs with
current traitSet, but each trait is the default
trait value.
|
RelTraitSet |
getDefaultSansConvention()
Returns a new traitSet with same traitDefs with
current traitSet, but each trait except
Convention
is the default trait value. |
<T extends RelDistribution> |
getDistribution()
Returns
RelDistribution trait defined by
RelDistributionTraitDef.INSTANCE, or null if the
RelDistributionTraitDef.INSTANCE is not registered
in this traitSet. |
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() |
boolean |
isDefault()
Returns whether all the traits are default trait value.
|
boolean |
isDefaultSansConvention()
Returns whether all the traits except
Convention
are default trait value. |
<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,
Supplier<? extends T> traitSupplier)
If a given trait is enabled, replaces it by calling the given function.
|
<T extends RelMultipleTrait> |
replaceIfs(RelTraitDef<T> def,
Supplier<? extends 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, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic 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> @Nullable 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, Supplier<? extends List<T>> traitSupplier)
public <T extends RelTrait> RelTraitSet replaceIf(RelTraitDef<T> def, Supplier<? extends T> traitSupplier)
public RelTraitSet apply(Mappings.TargetMapping mapping)
mapping - Mappingpublic boolean isDefault()
public boolean isDefaultSansConvention()
Convention
are default trait value.public boolean equalsSansConvention(RelTraitSet other)
Convention
equals with traits in other traitSet.public RelTraitSet getDefault()
public RelTraitSet getDefaultSansConvention()
Convention
is the default trait value. Convention trait
remains the same with current traitSet.public @Nullable Convention getConvention()
Convention trait defined by
ConventionTraitDef.INSTANCE, or null if the
ConventionTraitDef.INSTANCE is not registered
in this traitSet.public <T extends RelDistribution> T getDistribution()
RelDistribution trait defined by
RelDistributionTraitDef.INSTANCE, or null if the
RelDistributionTraitDef.INSTANCE is not registered
in this traitSet.public <T extends RelCollation> T getCollation()
RelCollation trait defined by
RelCollationTraitDef.INSTANCE, or null if the
RelCollationTraitDef.INSTANCE is not registered
in this traitSet.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(@Nullable 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>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-2022 Apache Software Foundation. All Rights Reserved.