Class Entity

java.lang.Object
com.loop54.model.Entity

public class Entity extends Object
An entity represents one Product (or document). It is identified by the id and type and contains named attributes.
  • Field Details

    • type

      public String type
      The type of the entity. This is usually "Product". This is used to distinguish between products and non-product entities (such as content).
    • id

      public String id
      The unique id of the entity. Could for instance be a SKU id.
  • Constructor Details

    • Entity

      public Entity(String type, String id)
      Parameters:
      type - The type of the entity. This is usually "Product".
      id - The unique id of the entity. Could for instance be a SKU id.
  • Method Details

    • getAttributes

      public List<EntityAttribute> getAttributes()
      All attributes available on the entity. When sending an Entity with a CreateEvent call these are not necessary to be set.
      Returns:
      All attributes available on the entity.
    • setAttributes

      public void setAttributes(List<EntityAttribute> attributes)
      Parameters:
      attributes - A list of attributes to set on the entity
    • getAttributeValueOrNull

      public <T> T getAttributeValueOrNull(String name, Class<T> clazz)
      Gets the attribute value with the desired name and type.
      Type Parameters:
      T - The expected type of the value in the attribute.
      Parameters:
      name - Name of the attribute.
      clazz - Type of the attribute. This needs to match what the library has deserialized or an exception will be thrown.
      Returns:
      The attribute value. If more than one attribute exist the first one will be returned. If the attribute does not exist null will be returned.
    • getAttributeValuesOrNull

      public <T> List<T> getAttributeValuesOrNull(String name, Class<T> clazz)
      Gets the attribute values with the desired name and type.
      Type Parameters:
      T - The expected type of the value in the attribute.
      Parameters:
      name - Name of the attribute.
      clazz - Type of the attribute. This needs to match what the library has deserialized or an exception will be thrown.
      Returns:
      All values related to the attribute as an array or null if the attribute does not exist.