Class AbstractEntity

java.lang.Object
com.smeup.kokos.sdk.entity.model.AbstractEntity

public abstract class AbstractEntity extends Object
The model of generic entity
  • Constructor Details

    • AbstractEntity

      public AbstractEntity()
  • Method Details

    • getType

      public String getType()
    • setType

      public void setType(String type)
    • getParameter

      public String getParameter()
    • setParameter

      public void setParameter(String parameter)
    • getId

      public abstract String getId()
    • setId

      public abstract void setId(String id)
    • getDescriptionValue

      public final String getDescriptionValue()
      Gets back the value of the field annotated with @Description, otherwise it fallbacks on the getId() method.
    • getOavs

      public final List<OavDescriptor> getOavs()
      Gets back the list of OAV descriptors for this entity, derived purely from the SmeupOav and Id annotations on its declared fields.
      Returns:
      an ordered list of OavDescriptor matching field declaration order
    • getActions

      public final List<ActionDescriptor> getActions()
      Gets back the list of Action descriptors for this entity, derived purely from the Action annotations on its declared methods.
      Returns:
      an ordered list of ActionDescriptor matching method declaration order
    • getOavValue

      public final Optional<Object> getOavValue(String oavId)
      Gets back the value of the field annotated with @SmeupOav with the given id.
      Parameters:
      oavId - the id of the OAV to look for
      Returns:
      an Optional containing the value of the OAV field, or empty if not found or inaccessible
    • getOavFields

      public List<Field> getOavFields(boolean includeId)
      Gets back the list of fields annotated with @SmeupOav, optionally including those also annotated with @Id.
      Parameters:
      includeId - if true, includes fields annotated with @Id; if false, excludes them
      Returns:
      a list of Fields annotated with @SmeupOav, filtered by the includeId flag
    • readFieldValue

      public final String readFieldValue(Field field)
      Reads the value of the given field from this entity instance, returning it as a String.
      Parameters:
      field - the Field to read, which should be accessible and belong to this entity class
      Returns:
      the String representation of the field's value, or an empty string if the field is inaccessible or null
    • getOavFields

      public static List<Field> getOavFields(Class<? extends AbstractEntity> entityClass, boolean includeId)
      Gets back the list of fields annotated with @SmeupOav for the given entity class, optionally including those also annotated with @Id.
      Parameters:
      entityClass - the entity class to inspect
      includeId - if true, includes fields annotated with @Id; if false, excludes them
      Returns:
      a list of Fields annotated with @SmeupOav, filtered by the includeId flag
    • isIdField

      public static boolean isIdField(Field field, SmeupOav smeupOav, String idOav)
      Determines if the given field is the id field, either by being annotated with @Id or by having an OAV id matching the default id.
      Parameters:
      field - the Field to check, which should be one of the OAV fields of the entity
      smeupOav - the SmeupOav annotation of the field, which should be provided to avoid repeated annotation lookups
      idOav - the default id OAV to compare against, typically obtained from getIdOav()
      Returns:
      true if the field is annotated with @Id or has an OAV id equal to idOav; false otherwise
    • getOavs

      public static List<OavDescriptor> getOavs(Class<? extends AbstractEntity> entityClass)
      Gets back the list of OAV descriptors for this entity, derived purely from the SmeupOav and Id annotations on its declared fields.
      Returns:
      an ordered list of OavDescriptor matching field declaration order