Package com.loop54.model
Class Entity
java.lang.Object
com.loop54.model.Entity
An entity represents one Product (or document). It is identified by the id and type and contains named attributes.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAll attributes available on the entity.<T> TgetAttributeValueOrNull(String name, Class<T> clazz) Gets the attribute value with the desired name and type.<T> List<T>getAttributeValuesOrNull(String name, Class<T> clazz) Gets the attribute values with the desired name and type.voidsetAttributes(List<EntityAttribute> attributes) SeegetAttributes().
-
Field Details
-
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
The unique id of the entity. Could for instance be a SKU id.
-
-
Constructor Details
-
Entity
- 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
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
SeegetAttributes().- Parameters:
attributes- A list of attributes to set on the entity
-
getAttributeValueOrNull
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
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.
-