Class VdmEntity<EntityT>

java.lang.Object
com.sap.cloud.sdk.datamodel.odata.helper.VdmObject<EntityT>
com.sap.cloud.sdk.datamodel.odata.helper.VdmEntity<EntityT>
Type Parameters:
EntityT - The specific entity data type.
Direct Known Subclasses:
VdmMediaEntity

public abstract class VdmEntity<EntityT> extends VdmObject<EntityT>
Represents a VdmObject which is an entity. Entities may have a version identifier.
  • Constructor Details

    • VdmEntity

      public VdmEntity()
  • Method Details

    • getVersionIdentifier

      @Nonnull public io.vavr.control.Option<String> getVersionIdentifier()
      Getter for the version identifier of this entity.

      This identifier can be used to compare this entity with a remote one. As not the whole entity has to be sent this reduces the request overhead.

      Actual use cases can be checking whether this entity is still current with regards to the remote entity, and ensuring that a update/delete operation is done on the expected version of the remote entity.

      Returns:
      The optional version identifier.
    • setVersionIdentifier

      public void setVersionIdentifier(@Nullable String versionIdentifier)
      Setter for the version identifier of this entity.

      This identifier can be used to compare this entity with a remote one. As not the whole entity has to be sent this reduces the request overhead.

      Actual use cases can be checking whether this entity is still current with regards to the remote entity, and ensuring that a update/delete operation is done on the expected version of the remote entity.

      Parameters:
      versionIdentifier - The version identifier of this entity.
    • getEntityCollection

      @Nonnull protected abstract String getEntityCollection()
      Used by fluent helpers and navigation property methods to construct OData queries.
      Returns:
      EDMX name of the entity collection identifier.
    • getDefaultServicePath

      @Nullable protected String getDefaultServicePath()
      Used by fluent helpers and navigation property methods to construct OData queries.
      Returns:
      Default context path to the OData service. In other words, everything in between the protocol://hostname:port and the OData resource name (entity set, $metadata, etc.)
    • attachToService

      protected void attachToService(@Nullable String servicePath, @Nonnull Destination destination)
      Sets the service path and destination for the fetch commands of this entity. Also applies to any associated entities (navigation properties) that were previously fetched.

      Note: Use with caution, as this can easily break the fetch calls on this entity. See the interface of the corresponding service for the default service path.

      Parameters:
      servicePath - Optional parameter. New service path to apply to this entity and any associated entities that were previously fetched. If a null value is provided and the service path has never been set, then the service path will be set to the default defined in the corresponding service interface.
      destination - New destination to apply to this entity and any associated entities that were previously fetched.
    • fetchFieldAsList

      @Nonnull protected <T extends VdmEntity<T>> List<T> fetchFieldAsList(@Nonnull String fieldName, @Nonnull Class<T> fieldType)
      Helper method to lazily resolve a field value from current entity.
      Type Parameters:
      T - The generic type parameter.
      Parameters:
      fieldName - The field name to lookup.
      fieldType - The field type to cast the value to.
      Returns:
      A list of requested values.
    • fetchFieldAsSingle

      @Nonnull protected <T extends VdmEntity<T>> T fetchFieldAsSingle(@Nonnull String fieldName, @Nonnull Class<T> fieldType)
      Helper method to lazily resolve a field value from current entity.
      Type Parameters:
      T - The generic type parameter.
      Parameters:
      fieldName - The field name to lookup.
      fieldType - The field type to cast the value to.
      Returns:
      The requested values.
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class VdmObject<EntityT>
    • canEqual

      protected boolean canEqual(@Nullable Object other)
      Overrides:
      canEqual in class VdmObject<EntityT>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class VdmObject<EntityT>
    • getServicePathForFetch

      protected String getServicePathForFetch()
      The service path only used for the fetch commands of this entity.

      Note: Use with caution, as this can easily break the fetch call on this entity. See the interface of the corresponding service for the default service path.

    • setServicePathForFetch

      protected void setServicePathForFetch(String servicePathForFetch)
      The service path only used for the fetch commands of this entity.

      Note: Use with caution, as this can easily break the fetch call on this entity. See the interface of the corresponding service for the default service path.

    • getDestinationForFetch

      protected Destination getDestinationForFetch()
      Convienence field for reusing the same destination with multiple queries (e.g. fetching associated entities).
      Returns:
      The stored destination for executing queries, or null if no such context has been set.
    • setDestinationForFetch

      protected void setDestinationForFetch(Destination destinationForFetch)
      Convienence field for reusing the same destination with multiple queries (e.g. fetching associated entities).
      Parameters:
      destination - New destination to apply to this entity