Interface CayennePath
- All Superinterfaces:
Iterable<CayennePathSegment>
,Serializable
This interface represents some path in the Cayenne model. Value is just a string of comma-separated identifiers.
Usage:
CayennePath path = CayennePath.of("a.b+");
CayennePath nextPath = path.dot("c+");
CayennePath root = path.head(1);
CayennePathSegment last = path.last();
if(last.isOuterJoin()) {
// ...
}
It could be used in expressions or in the internal processing logic. Implementation tries to optimize performance of the common path-related logic or at least shift costs from operation side to the initialization.
- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CayennePath
Constant value for an empty pathstatic final int
No special markersstatic final int
Prefetch path marker TODO: this marker used only for prefetch processing -
Method Summary
Modifier and TypeMethodDescriptiondefault CayennePath
Create new path appending next segment to this.default CayennePath
dot
(CayennePath next) Create new path appending all segments of the next path to this.default CayennePath
dot
(CayennePathSegment next) Create new path appending next segment to this.default CayennePathSegment
first()
Get the first segment of this path if it's not emptydefault boolean
hasMarker
(int marker) Check if this path has required markerdefault CayennePath
head
(int end) Create sub path from this path from the first element and ending at the given index.default boolean
isEmpty()
Check if this path is emptydefault CayennePathSegment
last()
Get the last segment of this path if it's not emptydefault int
length()
Get length of this path is segmentsdefault int
marker()
Get marker of this path orNO_MARKER
if non setstatic CayennePath
Create path from a given Stringstatic CayennePath
Create path from a given String with a marker.static CayennePath
of
(List<CayennePathSegment> segments) Create path from a given list ofCayennePathSegment
static CayennePath
of
(List<CayennePathSegment> segments, int marker) Create path from a given list ofCayennePathSegment
and a markerstatic CayennePath
of
(CayennePath path, int marker) Clone given path with a different markerdefault CayennePath
parent()
Get the parent path, that is a path up to the last segment of this path.static CayennePathSegment
static CayennePathSegment
segments()
Get all segments of this pathdefault CayennePath
tail
(int start) Create sub path from this path starting from the given index and to the end.toString()
default String
value()
Get string representation of this path, it'll be dot-separated segments of this path.default CayennePath
withMarker
(int marker) Clone this path with new markerMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Field Details
-
NO_MARKER
static final int NO_MARKERNo special markers- See Also:
-
PREFETCH_MARKER
static final int PREFETCH_MARKERPrefetch path marker TODO: this marker used only for prefetch processing- See Also:
-
EMPTY_PATH
Constant value for an empty path
-
-
Method Details
-
of
Create path from a given StringThis method will return
EMPTY_PATH
ifnull
or an empty string is provided as an argument.This method will throw
IllegalArgumentException
if path value is malformed (e.g. containing dot at the start of two consecutive dots).- Parameters:
path
- dot-separated path value- Returns:
- path for the given value
-
of
Create path from a given String with a marker.This method will return
EMPTY_PATH
ifnull
or an empty string is provided as an argument.This method will throw
IllegalArgumentException
if path value is malformed (e.g. containing dot at the start of two consecutive dots).- Parameters:
path
- dot-separated path valuemarker
- to use for a path- Returns:
- path for the given value
- See Also:
-
of
Clone given path with a different marker- Parameters:
path
- to clonemarker
- to set- Returns:
- clone of a given path with new marker
- See Also:
-
of
Create path from a given list ofCayennePathSegment
- Parameters:
segments
- list of path segments- Returns:
- path containing given segments
-
of
Create path from a given list ofCayennePathSegment
and a marker- Parameters:
segments
- list of path segmentsmarker
- to set- Returns:
- path containing given segments
- See Also:
-
segmentOf
-
segmentOf
-
segments
List<CayennePathSegment> segments()Get all segments of this path- Returns:
- list of segments
-
marker
default int marker()Get marker of this path orNO_MARKER
if non set- Returns:
- marker
- See Also:
-
withMarker
Clone this path with new marker- Parameters:
marker
- to use- Returns:
- new path with a marker
- See Also:
-
hasMarker
default boolean hasMarker(int marker) Check if this path has required marker- Parameters:
marker
- to check- Returns:
- true if this path has the marker
- See Also:
-
length
default int length()Get length of this path is segments- Returns:
- segments count
-
isEmpty
default boolean isEmpty()Check if this path is empty- Returns:
- true if this path has no segments
-
toString
String toString() -
value
Get string representation of this path, it'll be dot-separated segments of this path.- Returns:
- string value for this path
-
first
Get the first segment of this path if it's not empty- Returns:
- segment or null if path is empty
-
last
Get the last segment of this path if it's not empty- Returns:
- segment or null if path is empty
-
tail
Create sub path from this path starting from the given index and to the end.- Parameters:
start
- index from- Returns:
- a new path starting from the start index
-
head
Create sub path from this path from the first element and ending at the given index.- Parameters:
end
- index to- Returns:
- a new path ending at the end index
-
parent
Get the parent path, that is a path up to the last segment of this path.- Returns:
- parent path
-
dot
Create new path appending next segment to this.- Parameters:
next
- segment to append- Returns:
- new path equal to this path + next segment
-
dot
Create new path appending next segment to this.- Parameters:
next
- segment to append- Returns:
- new path equal to this path + next segment
-
dot
Create new path appending all segments of the next path to this.- Parameters:
next
- path to append- Returns:
- new path equal to this path + next path
-