Interface AggregatePath
- All Superinterfaces:
Comparable<AggregatePath>, Iterable<AggregatePath>
Represents a path within an aggregate starting from the aggregate root. The path can be iterated from the leaf to its
root.
It implements Comparable so that collections of AggregatePath instances can be sorted in a consistent
way.
- Since:
- 3.2
- Author:
- Jens Schauder, Mark Paluch
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic classA group ofAggregatePath.ColumnInfovalues referenced by there respectiveAggregatePath.static final recordInformation about a table underlying an entity. -
Method Summary
Modifier and TypeMethodDescriptionappend(AggregatePath path) Creates a new path by extending the current path by the path passed as an argument.append(RelationalPersistentProperty property) Creates a new path by extending the current path by the property passed as an argument.default intcompareTo(AggregatePath other) Compares thisAggregatePathto anotherAggregatePathbased on their dot path notation.default @Nullable AggregatePathfilter(Predicate<? super AggregatePath> predicate) Filter the AggregatePath returning the first item matching the givenPredicate.default AggregatePath.ColumnInfoReturns the longest ancestor path that has anIdproperty.@Nullable RelationalPersistentEntity<?> TheRelationalPersistentEntityassociated with the leaf of this path.default intReturns the path length for the aggregate path.Returns the path that has the same beginning but is one segment shorter than this path.default RelationalPersistentPropertydefault RelationalPersistentEntity<?> TheRelationalPersistentEntityassociated with the leaf of this path or throwIllegalStateExceptionif the leaf cannot be resolved.default RelationalPersistentPropertydefault AggregatePathThe required path resulting from removing the first element of theAggregatePathor throwingIllegalStateExceptionfor anyAggregatePathhaving less than two elements.getSubPathBasedOn(Class<?> baseType) default AggregatePath.TableInfo@Nullable AggregatePathgetTail()The path resulting from removing the first element of theAggregatePath.booleanbooleanbooleanReturns true exactly when the path is non-empty and the leaf property an embedded one.booleanisEntity()booleanisMap()booleanReturns true if there are multiple values for this path, i.e. if the path contains at least one element that is a collection and array or a map. // TODO: why does this return true if the parent entity is a collection?booleanbooleanbooleanisRoot()booleandefault Stream<AggregatePath> stream()@Nullable AggregatePathsubtract(@Nullable AggregatePath basePath) Subtract the basePath from this AggregatePath by removing the basePath from the beginning of this.Returns the dot based path notation usingPersistentProperty.getName().Methods inherited from interface Iterable
forEach, iterator, spliterator
-
Method Details
-
getParentPath
AggregatePath getParentPath()Returns the path that has the same beginning but is one segment shorter than this path.- Returns:
- the parent path. Guaranteed to be not null.
- Throws:
IllegalStateException- when called on an empty path.
-
append
Creates a new path by extending the current path by the property passed as an argument.- Parameters:
property- must not be null.- Returns:
- Guaranteed to be not null.
-
append
Creates a new path by extending the current path by the path passed as an argument.- Parameters:
path- must not be null.- Returns:
- Guaranteed to be not null.
- Since:
- 4.0
-
isRoot
boolean isRoot()- Returns:
- true if this is a root path for the underlying type.
-
getLength
default int getLength()Returns the path length for the aggregate path.- Returns:
- the path length for the aggregate path
-
isWritable
boolean isWritable() -
isEntity
boolean isEntity()- Returns:
- true when this is an empty path or the path references an entity.
-
isEmbedded
boolean isEmbedded()Returns true exactly when the path is non-empty and the leaf property an embedded one.- Returns:
- if the leaf property is embedded.
-
isMultiValued
boolean isMultiValued()Returns true if there are multiple values for this path, i.e. if the path contains at least one element that is a collection and array or a map. // TODO: why does this return true if the parent entity is a collection? This seems to mix some concepts that belong to somewhere else. // TODO: Multi-valued could be understood for embeddables with more than one column (i.e. composite primary keys)- Returns:
- true if the path contains a multivalued element.
-
isQualified
-
isMap
boolean isMap()- Returns:
- true if the leaf property of this path is a
Map. - See Also:
-
isCollectionLike
boolean isCollectionLike()- Returns:
- true when this is references a
Collectionor an array.
-
isOrdered
boolean isOrdered()- Returns:
- whether the leaf end of the path is ordered, i.e. the data to populate must be ordered.
- See Also:
-
hasIdProperty
boolean hasIdProperty()- Returns:
- true if this path represents an entity which has an identifier attribute.
-
getRequiredIdProperty
RelationalPersistentProperty getRequiredIdProperty() -
getRequiredPersistentPropertyPath
PersistentPropertyPath<RelationalPersistentProperty> getRequiredPersistentPropertyPath()- Returns:
- the persistent property path if the path is not a
rootpath. - Throws:
IllegalStateException- if the current path is arootpath.- See Also:
-
getRequiredBaseProperty
- Returns:
- the base property.
- Throws:
IllegalStateException- if the current path is arootpath.- See Also:
-
getRequiredLeafProperty
- Returns:
- the leaf property.
- Throws:
IllegalStateException- if the current path is arootpath.- See Also:
-
getLeafEntity
@Nullable RelationalPersistentEntity<?> getLeafEntity()TheRelationalPersistentEntityassociated with the leaf of this path.- Returns:
- Might return null when called on a path that does not represent an entity.
-
getRequiredLeafEntity
TheRelationalPersistentEntityassociated with the leaf of this path or throwIllegalStateExceptionif the leaf cannot be resolved.- Returns:
- the required
RelationalPersistentEntityassociated with the leaf of this path. - Throws:
IllegalStateException- if the persistent entity cannot be resolved.
-
toDotPath
String toDotPath()Returns the dot based path notation usingPersistentProperty.getName().- Returns:
- will never be null.
-
getTableInfo
-
getColumnInfo
-
filter
Filter the AggregatePath returning the first item matching the givenPredicate.- Parameters:
predicate- must not be null.- Returns:
- the first matching element or null.
-
stream
- Returns:
- will never be null.
-
getIdDefiningParentPath
AggregatePath getIdDefiningParentPath()Returns the longest ancestor path that has anIdproperty.- Returns:
- a path that starts just as this path but is shorter. Guaranteed to be not null.
- Throws:
IllegalStateException- if the current path is not arootpath or if there is no identifier associated.
-
getTail
@Nullable AggregatePath getTail()The path resulting from removing the first element of theAggregatePath.- Returns:
- null for any
AggregatePathhaving less than two elements. - Since:
- 4.0
-
getRequiredTail
The required path resulting from removing the first element of theAggregatePathor throwingIllegalStateExceptionfor anyAggregatePathhaving less than two elements.- Throws:
IllegalStateException- for anyAggregatePathhaving less than two elements.- Since:
- 4.0
-
subtract
Subtract the basePath from this AggregatePath by removing the basePath from the beginning of this.- Parameters:
basePath- the path to be removed.- Returns:
- an AggregatePath that ends like the original AggregatePath but has basePath removed from the beginning.
- Since:
- 4.0
-
compareTo
Compares thisAggregatePathto anotherAggregatePathbased on their dot path notation.This is used to get
AggregatePathinstances sorted in a consistent way. Since this order affects generated SQL this also affects query caches and similar.- Specified by:
compareToin interfaceComparable<AggregatePath>- Parameters:
other- theAggregatePathto compare to. Must not be null.- Returns:
- a negative integer, zero, or a positive integer as this object's path is less than, equal to, or greater than the specified object's path.
- Since:
- 4.0
-
getSubPathBasedOn
-