Class ODataEntityKey
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.client.request.AbstractODataParameters
com.sap.cloud.sdk.datamodel.odata.client.request.ODataEntityKey
Fluent API class to build and hold entity keys. A key is comprised of one or multiple individual key-value pairs.
-
Constructor Summary
ConstructorDescriptionODataEntityKey
(ODataProtocol protocol) Create a new, empty entity key for the given protocol version. -
Method Summary
Modifier and TypeMethodDescriptionaddKeyProperties
(Map<String, Object> properties) Add properties to the OData entity key.<PrimitiveT>
ODataEntityKeyaddKeyProperty
(String propertyName, PrimitiveT value) Add an entity property to this key.Get all field names that are part of this key.static ODataEntityKey
of
(Map<String, Object> key, ODataProtocol protocol) Create an instance ofODataEntityKey
from a generic key-value composition.toEncodedString
(UriEncodingStrategy strategy) Serializes all parameters into an encoded URL path segment.toString()
Serializes the entity key into an unencoded OData URL format for entity keys.Methods inherited from class com.sap.cloud.sdk.datamodel.odata.client.request.AbstractODataParameters
getProtocol, toEncodedString
-
Constructor Details
-
ODataEntityKey
Create a new, empty entity key for the given protocol version.- Parameters:
protocol
- TheODataProtocol
version this key should conform to.
-
-
Method Details
-
getFieldNames
Get all field names that are part of this key.- Returns:
- A set of entity property field names.
-
addKeyProperty
@Nonnull public <PrimitiveT> ODataEntityKey addKeyProperty(@Nonnull String propertyName, @Nullable PrimitiveT value) Add an entity property to this key.- Type Parameters:
PrimitiveT
- Type of the primitive value.- Parameters:
propertyName
- Name of the property (derived from the EDMX)value
- Property value, assumed to be a primitive.- Returns:
- The modified instance.
- Throws:
IllegalArgumentException
- When a parameter by that idenfitier already exists or primitive type is not supported.
-
addKeyProperties
Add properties to the OData entity key.- Parameters:
properties
- The key-value mapping.- Returns:
- The same instance.
- Throws:
IllegalArgumentException
- When the map contains a primitive type that is not supported.- See Also:
-
of
@Nonnull public static ODataEntityKey of(@Nonnull Map<String, Object> key, @Nonnull ODataProtocol protocol) Create an instance ofODataEntityKey
from a generic key-value composition.- Parameters:
key
- Key-value pairs of entity properties and their values.protocol
- TheODataProtocol
version this key should conform to.- Returns:
- A new instance of
ODataEntityKey
. - Throws:
IllegalArgumentException
- When the map contains a primitive type that is not supported.- See Also:
-
toEncodedString
Description copied from class:AbstractODataParameters
Serializes all parameters into an encoded URL path segment. The format is as follows:- An empty set of parameters will yield
()
- A single parameter entry will yield
(value)
- Multiple of parameters will yield
(key1=val,key2=val)
- Overrides:
toEncodedString
in classAbstractODataParameters
- Parameters:
strategy
- The URI encoding strategy.- Returns:
- Encoded URL string representation of the parameters.
- An empty set of parameters will yield
-
toString
Serializes the entity key into an unencoded OData URL format for entity keys.- Overrides:
toString
in classAbstractODataParameters
- Returns:
- Encoded URL string representation of entity key.
-