Class ODataResourcePath
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.client.expression.ODataResourcePath
A class that assembles resource references into a URL path. References can be entity sets, entities by key,
properties, functions, actions and special endpoints like the metadata endpoint.
E.g. the following resource path identifies a function invocation on the a navigational property of the entity
identified by
'val'
:
Entity(key='val')/NavigationProperty/Model.Function(1)/ResultProperty
.
Of the result only the property ResultProperty
is accessed.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddParameterToLastSegment
(AbstractODataParameters parameters) Add a path parameter to the last segment.addSegment
(String segment) Add a navigation to the path.addSegment
(String segment, AbstractODataParameters parameters) Add a navigation with a parameters or function or action call to the path.boolean
List<io.vavr.Tuple2<String,
AbstractODataParameters>> The current path as a list of its individual path segments.int
hashCode()
static ODataResourcePath
Convenience method fornew ODataResourcePath().addSegment(segment)
.static ODataResourcePath
of
(String segment, AbstractODataParameters segmentParameter) Convenience method fornew ODataResourcePath().addSegment(segment, segmentParameter)
.Encodes the path segments and assembles them together.toEncodedPathString
(UriEncodingStrategy strategy) Encodes the path segments and assembles them together.toString()
Builds the path segments to a full URL path.
-
Constructor Details
-
ODataResourcePath
public ODataResourcePath()
-
-
Method Details
-
of
Convenience method fornew ODataResourcePath().addSegment(segment)
. It creates a new resource path for the given path string.- Parameters:
segment
- The string identifying the resource e.g.EntityName
- Returns:
- A new
ODataResourcePath
.
-
of
@Nonnull public static ODataResourcePath of(@Nonnull String segment, @Nonnull AbstractODataParameters segmentParameter) Convenience method fornew ODataResourcePath().addSegment(segment, segmentParameter)
. It creates a new resource path for the given path string and parameters.- Parameters:
segment
- The string identifying the resource e.g.EntityName
segmentParameter
- The parameters to be included in this segment e.g.(key1='val',key2=123)
- Returns:
- A new
ODataResourcePath
.
-
addSegment
Add a navigation to the path.- Parameters:
segment
- The navigation to add. Any slashes will be encoded and not treated as segment separators.- Returns:
- This builder instance.
-
addSegment
@Nonnull public ODataResourcePath addSegment(@Nonnull String segment, @Nullable AbstractODataParameters parameters) Add a navigation with a parameters or function or action call to the path.- Parameters:
segment
- The unencoded navigation or function or action reference to add. Any slashes will be encoded and not treated as segment separators.parameters
- The unencoded parameters or parameters to add.- Returns:
- This builder instance.
-
addParameterToLastSegment
@Nonnull public ODataResourcePath addParameterToLastSegment(@Nonnull AbstractODataParameters parameters) Add a path parameter to the last segment. Can only be applied if the last segment added to this builder did not contain any parameters.- Parameters:
parameters
- The unencoded parameters to add.- Returns:
- This builder instance.
- Throws:
IllegalStateException
- When the current path is empty or the last segment already contains a parameter.
-
toEncodedPathString
Encodes the path segments and assembles them together. The returned path will always start with a leading forward slash and ends without any trailing slashes.- Returns:
- The encoded path.
-
toEncodedPathString
Encodes the path segments and assembles them together. The returned path will always start with a leading forward slash and ends without any trailing slashes.- Parameters:
strategy
- The URI encoding strategy.- Returns:
- The encoded path.
-
toString
Builds the path segments to a full URL path. -
equals
-
hashCode
public int hashCode() -
getSegments
The current path as a list of its individual path segments.
-