Class VdmObject<ObjectT>
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.helper.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
Modifier and TypeFieldDescriptionA mapping of the OData field name to the original value. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
protected void
Sets the values of all custom fields contained in the givenvalues
.Returns map of all fields which have been changed on this entity along with their updated values.<FieldT> FieldT
getCustomField
(EntityField<ObjectT, FieldT> 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 all custom fields of this object.Returns all custom field names and values of this object.getKey()
Returns the compound key of this object.Returns a set of all custom field names contained in this object.Returns a set of all field names contained in this object.Returns a set of all navigation property names contained in this object.getType()
Returns the class of this object.boolean
hasCustomField
(EntityField<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
(EntityField<ObjectT, FieldT> 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()
Returns a map of all fields, navigation properties, and custom fields contained in this object.Returns a map of all custom fields contained in this object.Returns a map of all fields contained in this object.Returns a map of all navigation properties contained in this object.toString()
-
Field Details
-
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 all custom fields of this object.- Returns:
- The names of the custom fields of this object.
-
getCustomFields
Returns all custom field names and values of this object.- Returns:
- All 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 EntityField<ObjectT, FieldT> 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 NoSuchEntityFieldException 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:
NoSuchEntityFieldException
- if no field with the given name could be found.
-
getCustomField
@Nullable public <FieldT> FieldT getCustomField(@Nonnull EntityField<ObjectT, FieldT> customField) throws NoSuchEntityFieldExceptionThis 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:
NoSuchEntityFieldException
- if no field with the given name could be found.
-
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
Sets the values of all custom fields contained in the givenvalues
.Afterwards, marks all fields as unchanged.
- Parameters:
values
- The map of custom fields to set.
-
toMapOfCustomFields
Returns a map of all custom fields contained in this object.- Returns:
- A map of all custom fields contained in this object.
-
getSetOfCustomFields
Returns a set of all custom field names contained in this object.- Returns:
- A set of all custom field names contained in this object.
-
toMapOfFields
Returns a map of all fields contained in this object.- Returns:
- A map of all fields contained in this object.
-
getSetOfFields
Returns a set of all field names contained in this object.- Returns:
- A set of all field names contained in this object.
-
toMap
Returns a map of all fields, navigation properties, and custom fields contained in this object.- Returns:
- A map of all fields, navigation properties, and custom fields contained in this object.
-
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()
-