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 CayennePathConstant value for an empty pathstatic final intNo special markersstatic final intPrefetch path marker TODO: this marker used only for prefetch processing -
Method Summary
Modifier and TypeMethodDescriptiondefault CayennePathCreate new path appending next segment to this.default CayennePathdot(CayennePath next) Create new path appending all segments of the next path to this.default CayennePathdot(CayennePathSegment next) Create new path appending next segment to this.default CayennePathSegmentfirst()Get the first segment of this path if it's not emptydefault booleanhasMarker(int marker) Check if this path has required markerdefault CayennePathhead(int end) Create sub path from this path from the first element and ending at the given index.default booleanisEmpty()Check if this path is emptydefault CayennePathSegmentlast()Get the last segment of this path if it's not emptydefault intlength()Get length of this path is segmentsdefault intmarker()Get marker of this path orNO_MARKERif non setstatic CayennePathCreate path from a given Stringstatic CayennePathCreate path from a given String with a marker.static CayennePathof(List<CayennePathSegment> segments) Create path from a given list ofCayennePathSegmentstatic CayennePathof(List<CayennePathSegment> segments, int marker) Create path from a given list ofCayennePathSegmentand a markerstatic CayennePathof(CayennePath path, int marker) Clone given path with a different markerdefault CayennePathparent()Get the parent path, that is a path up to the last segment of this path.static CayennePathSegmentstatic CayennePathSegmentsegments()Get all segments of this pathdefault CayennePathtail(int start) Create sub path from this path starting from the given index and to the end.toString()default Stringvalue()Get string representation of this path, it'll be dot-separated segments of this path.default CayennePathwithMarker(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_PATHifnullor an empty string is provided as an argument.This method will throw
IllegalArgumentExceptionif 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_PATHifnullor an empty string is provided as an argument.This method will throw
IllegalArgumentExceptionif 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 ofCayennePathSegmentand 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_MARKERif 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
-