Class VdmObject<ObjectT>
java.lang.Object
com.sap.cloud.sdk.datamodel.odatav4.core.VdmObject<ObjectT>
- Type Parameters:
ObjectT
- The type of the implementing object.
- Direct Known Subclasses:
VdmComplex
,VdmEntity
Superclass of all entities which contains common elements such as a generic representation of custom fields.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
protected void
Read entity data from generic map.Returns the annotation properties.Returns map of all fields which have been changed on this entity along with their updated values.<FieldT> FieldT
getCustomField
(SimpleProperty<ObjectT> customField) This method allows for retrieval of custom fields that are added to the underlying OData services.<FieldT> FieldT
getCustomField
(String customFieldName) This method allows for retrieval of custom fields that are added to the underlying OData services.Returns the names of the custom fields of this object.Returns the names and values of a custom field.protected ODataEntityKey
getKey()
Returns the compound key of this object.abstract String
Returns the EDMX type of this entity.Get the custom field names.Get the field names.Get navigation property names as set.getType()
Returns the class of this object.boolean
hasCustomField
(SimpleProperty<ObjectT> customField) Checks whether this object contains a value for the given custom field.boolean
hasCustomField
(String customFieldName) Checks whether this object contains a custom field with the given name.int
hashCode()
protected void
rememberChangedField
(String fieldName, Object valueBeforeChange) Remembers the original value of a changed field.void
Resets the map of all fields which have been changed on this entity.<FieldT> void
setCustomField
(SimpleProperty<ObjectT> customField, FieldT value) Sets the value of a single custom field.void
setCustomField
(String customFieldName, Object value) Sets the value of a single custom field.toMap()
Translate the entity data to key-value map.Get the custom fields as value map.Get all fields as map.Get navigation properties as map.toString()
-
Field Details
-
ODATA_TYPE_ANNOTATIONS
The OData V4 JSON key to access an entity EDM type definition. -
ODATA_VERSION_ANNOTATIONS
The OData V4 JSON key to access an entity version identifier. -
changedOriginalFields
A mapping of the OData field name to the original value.This should be updated via
rememberChangedField(String, Object)
on every set call of a property.
-
-
Constructor Details
-
VdmObject
public VdmObject()
-
-
Method Details
-
getCustomFieldNames
Returns the names of the custom fields of this object.- Returns:
- The names of the custom fields of this object.
-
getCustomFields
Returns the names and values of a custom field.- Returns:
- All of the names & values of custom fields as a map.
-
setCustomField
Sets the value of a single custom field.- Parameters:
customFieldName
- Name of the custom field.value
- Value of the custom field.
-
setCustomField
public <FieldT> void setCustomField(@Nonnull SimpleProperty<ObjectT> customField, @Nullable FieldT value) Sets the value of a single custom field. If the EntityField passed as parameter holds a TypeConverter, the value will be converted before it's stored.- Type Parameters:
FieldT
- The type of the custom field to set.- Parameters:
customField
- Name of the custom field, represented as an EntityField object.value
- Value of the custom field.
-
hasCustomField
Checks whether this object contains a custom field with the given name.- Parameters:
customFieldName
- Name of the custom field to check for- Returns:
true
if this entity has a custom field with the given name,false
otherwise.
-
hasCustomField
Checks whether this object contains a value for the given custom field.- Parameters:
customField
- Custom field to check for, represented as anEntityField
object.- Returns:
true
if this object has a custom field with the name of the given field,false
otherwise.
-
getCustomField
@Nullable public <FieldT> FieldT getCustomField(@Nonnull String customFieldName) throws NoSuchElementException This method allows for retrieval of custom fields that are added to the underlying OData services.- Type Parameters:
FieldT
- The type of the returned field.- Parameters:
customFieldName
- Name of the field returned by the underlying OData service.- Returns:
- The value of the custom field. Actual type will depend on the type configured in the underlying OData service.
- Throws:
NoSuchElementException
- if no field with the given name could be found.
-
getCustomField
@Nullable public <FieldT> FieldT getCustomField(@Nonnull SimpleProperty<ObjectT> customField) throws NoSuchElementException This method allows for retrieval of custom fields that are added to the underlying OData services. If the EntityField passed as parameter holds a TypeConverter, the value will be converted before it's returned.- Type Parameters:
FieldT
- The type of the returned field.- Parameters:
customField
- Field returned by the underlying OData service.- Returns:
- The value of the custom field. Actual type will depend on the type configured in the underlying OData service.
- Throws:
NoSuchElementException
- if no field with the given name could be found.
-
getAnnotationProperties
Returns the annotation properties.- Returns:
- List of OData annotation properties.
-
getOdataType
Returns the EDMX type of this entity.- Returns:
- The EDMX type of this entity.
-
getType
Returns the class of this object.- Returns:
- The class of this object.
-
getKey
Returns the compound key of this object.- Returns:
- The compound key of this object.
-
fromMap
Read entity data from generic map.- Parameters:
values
- The key-value map.
-
toMapOfCustomFields
Get the custom fields as value map.- Returns:
- The custom fields.
-
getSetOfCustomFields
Get the custom field names.- Returns:
- The custom field names.
-
toMapOfFields
Get all fields as map.- Returns:
- The fields as map.
-
getSetOfFields
Get the field names.- Returns:
- The field names.
-
toMap
Translate the entity data to key-value map.- Returns:
- The map representation of the entity.
-
getChangedFields
Returns map of all fields which have been changed on this entity along with their updated values.- Returns:
- Map containing all changed fields with their current value.
-
rememberChangedField
Remembers the original value of a changed field.- Parameters:
fieldName
- The name of the field that is changed.valueBeforeChange
- The original value before the change.
-
resetChangedFields
public void resetChangedFields()Resets the map of all fields which have been changed on this entity.After calling this method, no field is considered changed, until you change the value of fields on this entity afterwards.
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode()
-