Package org.springframework.data.mapping
Class PropertyPath
java.lang.Object
org.springframework.data.mapping.PropertyPath
- All Implemented Interfaces:
Iterable<PropertyPath>,Supplier<Stream<PropertyPath>>,Streamable<PropertyPath>
Abstraction of a
PropertyPath of a domain class.- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch, Mariusz MÄ…czkowski, Johannes Englmeier
-
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic PropertyPathstatic PropertyPathfrom(String source, TypeInformation<?> type) Returns the leaf property of thePropertyPath.Class<?>Returns the type of the leaf property of the currentPropertyPath.Returns the owning type of thePropertyPath.Returns the first part of thePropertyPath.Class<?>getType()Returns the actual type of the property.inthashCode()booleanhasNext()Returns whether there is a nestedPropertyPath.booleanReturns whether thePropertyPathis actually a collection.iterator()Returns anIterator<PropertyPath>that iterates over all the partial property paths with the same leaf type but decreasing length.Returns thePropertyPathfor the path nested under the current property.next()Returns thePropertyPathpath that results from removing the first element of the current one.Returns thePropertyPathin dot notation.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
getOwningType
Returns the owning type of thePropertyPath.- Returns:
- the owningType will never be null.
-
getSegment
Returns the first part of thePropertyPath. For example:PropertyPath.from("a.b.c", Some.class).getSegment();results ina.- Returns:
- the name will never be null.
-
getLeafProperty
Returns the leaf property of thePropertyPath.- Returns:
- will never be null.
-
getLeafType
Returns the type of the leaf property of the currentPropertyPath.- Returns:
- will never be null.
-
getType
Returns the actual type of the property. Will return the plain resolved type for simple properties, the component type for anyIterableor the value type of aMap.- Returns:
- the actual type of the property.
-
getTypeInformation
-
next
Returns thePropertyPathpath that results from removing the first element of the current one. For example:PropertyPath.from("a.b.c", Some.class).next().toDotPath();results in the output:b.c- Returns:
- the next nested
PropertyPathor null if no nestedPropertyPathavailable. - See Also:
-
hasNext
public boolean hasNext()Returns whether there is a nestedPropertyPath. If this returns true you can expectnext()to return a non- null value.- Returns:
-
toDotPath
Returns thePropertyPathin dot notation.- Returns:
- the
PropertyPathin dot notation.
-
isCollection
public boolean isCollection()Returns whether thePropertyPathis actually a collection.- Returns:
- true whether the
PropertyPathis actually a collection.
-
nested
Returns thePropertyPathfor the path nested under the current property.- Parameters:
path- must not be null or empty.- Returns:
- will never be null.
-
iterator
Returns anIterator<PropertyPath>that iterates over all the partial property paths with the same leaf type but decreasing length. For example:PropertyPath propertyPath = PropertyPath.from("a.b.c", Some.class); propertyPath.forEach(p -> p.toDotPath());results in the dot paths: *a.b.c b.c c
- Specified by:
iteratorin interfaceIterable<PropertyPath>
-
equals
-
hashCode
public int hashCode() -
from
Extracts thePropertyPathchain from the given sourceStringandTypeInformation.
UsesSPLITTERby default andSPLITTER_FOR_QUOTEDforquotedliterals.Separate parts of the path may be separated by
"."or by"_"or by camel case. When the match to properties is ambiguous longer property names are preferred. So for "userAddressCity" the interpretation "userAddress.city" is preferred over "user.address.city".- Parameters:
source- a String denoting the property path, must not be null.type- the owning type of the property path, must not be null.- Returns:
- a new
PropertyPathguaranteed to be not null.
-
from
Extracts thePropertyPathchain from the given sourceStringandTypeInformation.
UsesSPLITTERby default andSPLITTER_FOR_QUOTEDforquotedliterals.Separate parts of the path may be separated by
"."or by"_"or by camel case. When the match to properties is ambiguous longer property names are preferred. So for "userAddressCity" the interpretation "userAddress.city" is preferred over "user.address.city".- Parameters:
source- a String denoting the property path, must not be null.type- the owning type of the property path, must not be null.- Returns:
- a new
PropertyPathguaranteed to be not null.
-
toString
-