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 TypeMethodDescriptionboolean
static PropertyPath
static PropertyPath
from
(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.int
hashCode()
boolean
hasNext()
Returns whether there is a nestedPropertyPath
.boolean
Returns whether thePropertyPath
is actually a collection.iterator()
Returns anIterator<PropertyPath>
that iterates over all the partial property paths with the same leaf type but decreasing length.Returns thePropertyPath
for the path nested under the current property.next()
Returns thePropertyPath
path that results from removing the first element of the current one.Returns thePropertyPath
in dot notation.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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 anyIterable
or the value type of aMap
.- Returns:
- the actual type of the property.
-
getTypeInformation
-
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
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 thePropertyPath
in dot notation.- Returns:
- the
PropertyPath
in dot notation.
-
isCollection
public 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
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:
iterator
in interfaceIterable<PropertyPath>
-
equals
-
hashCode
public int hashCode() -
from
Extracts thePropertyPath
chain from the given sourceString
andTypeInformation
.
UsesSPLITTER
by default andSPLITTER_FOR_QUOTED
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 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
PropertyPath
guaranteed to be not null.
-
from
Extracts thePropertyPath
chain from the given sourceString
andTypeInformation
.
UsesSPLITTER
by default andSPLITTER_FOR_QUOTED
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 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
PropertyPath
guaranteed to be not null.
-
toString
-