Interface PropertyPath
- All Superinterfaces:
Iterable<PropertyPath>, Streamable<PropertyPath>, Supplier<Stream<PropertyPath>>
Abstraction of a
PropertyPath
within a domain class.- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch, Mariusz MÄ…czkowski, Johannes Englmeier
-
Method Summary
Modifier and TypeMethodDescriptionstatic PropertyPath
static PropertyPath
from
(String source, TypeInformation<?> type) default PropertyPath
Returns the leaf property of thePropertyPath
.default Class
<?> Returns the type of the leaf property of the currentPropertyPath
.Returns the owning type of thePropertyPath
.Returns the first part of thePropertyPath
.default Class
<?> getType()
Returns the actual type of the property.Returns the type information of the property.default boolean
hasNext()
Returns whether there is a nestedPropertyPath
.default boolean
Returns whether thePropertyPath
is actually a collection.iterator()
Returns anIterator of PropertyPath
that iterates over all the partial property paths with the same leaf type but decreasing length.default PropertyPath
Returns thePropertyPath
for the path nested under the current property.@Nullable PropertyPath
next()
Returns thePropertyPath
path that results from removing the first element of the current one.default String
Returns thePropertyPath
in dot notation.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
getOwningType
TypeInformation<?> getOwningType()Returns the owning type of thePropertyPath
.- Returns:
- the owningType will never be null.
-
getSegment
String 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
-
getTypeInformation
TypeInformation<?> getTypeInformation()Returns the type information of the property.- Returns:
- the actual type of the property.
-
next
@Nullable PropertyPath next()Returns thePropertyPath
path 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
PropertyPath
or null if no nestedPropertyPath
available. - See Also:
-
hasNext
default boolean hasNext()Returns whether there is a nestedPropertyPath
. If this returns true you can expectnext()
to return a non- null value.- Returns:
-
toDotPath
Returns thePropertyPath
in dot notation.- Returns:
- the
PropertyPath
in dot notation.
-
isCollection
default boolean isCollection()Returns whether thePropertyPath
is actually a collection.- Returns:
- true whether the
PropertyPath
is actually a collection.
-
nested
Returns thePropertyPath
for the path nested under the current property.- Parameters:
path
- must not be null or empty.- Returns:
- will never be null.
-
iterator
Iterator<PropertyPath> iterator()Returns anIterator of 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:
iterator
in interfaceIterable<PropertyPath>
-
from
Extracts thePropertyPath
chain from the given sourceString
andTypeInformation
.
Uses(?:[%s]?([%s]*?[^%s]+))
by default and(?:[%s]?([%s]*?[^%s]+))
forquoted
literals.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 foruserAddressCity
the interpretationuserAddress.city
is preferred overuser.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
PropertyPath
guaranteed to be not null.
-
from
Extracts thePropertyPath
chain from the given sourceString
andTypeInformation
.
Uses(?:[%s]?([%s]*?[^%s]+))
by default and(?:[%s]?([%s]*?[^%s]+))
forquoted
literals.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 foruserAddressCity
the interpretationuserAddress.city
is preferred overuser.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
PropertyPath
guaranteed to be not null.
-