Class DefaultIntegrationItem
- java.lang.Object
-
- de.hybris.platform.integrationservices.item.DefaultIntegrationItem
-
- All Implemented Interfaces:
IntegrationItem
public class DefaultIntegrationItem extends java.lang.Object implements IntegrationItem
Default implementation of theIntegrationIteminterface
-
-
Constructor Summary
Constructors Constructor Description DefaultIntegrationItem(@NotNull TypeDescriptor type, java.lang.String key)Instantiates this integration item.DefaultIntegrationItem(TypeDescriptor type, IntegrationItem containerItem)Instantiates this integration item.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.ObjectgetAttribute(TypeAttributeDescriptor attr)Retrieves value of an attribute.java.lang.ObjectgetAttribute(java.lang.String name)Retrieves value of an attribute.java.util.Collection<TypeAttributeDescriptor>getAttributes()Retrieves attributes present in this integration object.java.util.Optional<IntegrationItem>getContextItem(TypeDescriptor contextItemDescriptor)Retrieves a context item for the given TypeDescriptor if one exists.java.lang.StringgetIntegrationKey()Retrieves integration key value for this item.java.lang.StringgetIntegrationObjectCode()Retrieves code of theIntegrationObjectModelthis item belongs to.TypeDescriptorgetItemType()Retrieves type of this integration item.java.lang.ObjectgetLocalizedAttribute(java.lang.String attribute, java.lang.String lang)Reads value of a localized attribute.java.lang.ObjectgetLocalizedAttribute(java.lang.String attribute, java.util.Locale lang)Reads value of a localized attribute.IntegrationItemgetReferencedItem(TypeAttributeDescriptor attribute)Retrieves an integration item referenced by specified attribute.IntegrationItemgetReferencedItem(java.lang.String attribute)java.util.Collection<IntegrationItem>getReferencedItems(TypeAttributeDescriptor attribute)Retrieves multiple integration items referenced by specified attribute.java.util.Collection<IntegrationItem>getReferencedItems(java.lang.String attribute)inthashCode()booleansetAttribute(java.lang.String attrName, java.lang.Object value)Sets value of an attribute in this item.voidsetIntegrationKey(java.lang.String key)Sets the integrationKey on this item.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultIntegrationItem
public DefaultIntegrationItem(@NotNull @NotNull TypeDescriptor type, java.lang.String key)Instantiates this integration item.- Parameters:
type- descriptor of the item type this new instance will havekey- integration key of this item. Integration key can benull
-
DefaultIntegrationItem
public DefaultIntegrationItem(TypeDescriptor type, IntegrationItem containerItem)
Instantiates this integration item.- Parameters:
type- descriptor of the item type this new instance will havecontainerItem- the integration item which containsthisitem
-
-
Method Detail
-
getIntegrationObjectCode
public java.lang.String getIntegrationObjectCode()
Description copied from interface:IntegrationItemRetrieves code of theIntegrationObjectModelthis item belongs to.- Specified by:
getIntegrationObjectCodein interfaceIntegrationItem- Returns:
- value of the integration object code
-
getItemType
@Nonnull public TypeDescriptor getItemType()
Description copied from interface:IntegrationItemRetrieves type of this integration item.- Specified by:
getItemTypein interfaceIntegrationItem- Returns:
- descriptor of how integration object item is defined for this item.
-
getIntegrationKey
public java.lang.String getIntegrationKey()
Description copied from interface:IntegrationItemRetrieves integration key value for this item.- Specified by:
getIntegrationKeyin interfaceIntegrationItem- Returns:
- calculated integration key value for the item content.
-
getAttributes
public java.util.Collection<TypeAttributeDescriptor> getAttributes()
Description copied from interface:IntegrationItemRetrieves attributes present in this integration object.- Specified by:
getAttributesin interfaceIntegrationItem- Returns:
- a subset of all possible item attributes defined in
IntegrationItem.getItemType()item type, which were set in this integration item. Even if an attribute was set tonull, e.g.setAttribute("myAttribute", null), a type attribute descriptor will be returned for"myAttribute", if it's an attribute defined for the item type.
-
setAttribute
public boolean setAttribute(java.lang.String attrName, java.lang.Object value)Sets value of an attribute in this item.This method does enforce any invariants, e.g. attribute existence, match of the value type to the declared in the metadata, etc.
- Specified by:
setAttributein interfaceIntegrationItem- Parameters:
attrName- name of the attribute whose value needs to be set.value- a value for the attribute. In order to set a value for a localized attribute,LocalizedValueshould be passed as thevalue.- Returns:
true, if the value was successfully set, orfalse, if the specified attribute does not exist for this item.
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface:IntegrationItemRetrieves value of an attribute.- Specified by:
getAttributein interfaceIntegrationItem- Parameters:
name- name of the attribute to read.- Returns:
- value for the specified attribute in this item or
null, if the attribute has not been set yet or does not exist. If attribute is localized, thenLocalizedValueis returned.
-
getAttribute
public java.lang.Object getAttribute(TypeAttributeDescriptor attr)
Description copied from interface:IntegrationItemRetrieves value of an attribute.- Specified by:
getAttributein interfaceIntegrationItem- Parameters:
attr-TypeAttributeDescriptorthat contains the information to get the value- Returns:
- value for the specified attribute in this item or
null, if the attribute has not been set yet or does not exist. If attribute is localized, thenLocalizedValueis returned.
-
getLocalizedAttribute
public java.lang.Object getLocalizedAttribute(java.lang.String attribute, java.lang.String lang)Reads value of a localized attribute.- Specified by:
getLocalizedAttributein interfaceIntegrationItem- Parameters:
attribute- name of the attribute to readlang- ISO code of the language, e.g. 'en' or 'es_CO', for which the attribute should be read. This is the value that can be read fromLocaleasLocale.toLanguageTag()- Returns:
- value of the specified attribute in the specified language or
null, if either the attribute or the language does not have a value set. - Throws:
java.lang.IllegalArgumentException- when the attribute is not localized
-
getLocalizedAttribute
public java.lang.Object getLocalizedAttribute(java.lang.String attribute, java.util.Locale lang)Reads value of a localized attribute. This method should ensure the specified attribute is indeed localized. Otherwise, the implementations should not return a value or indicate the problem by throwing an exception.- Specified by:
getLocalizedAttributein interfaceIntegrationItem- Parameters:
attribute- name of the attribute to readlang- language, for which the attribute should be read- Returns:
- value of the specified attribute in the specified language or
null, if either the attribute or the language does not have a value set. - Throws:
java.lang.IllegalArgumentException- when the attribute is not localized
-
getReferencedItem
public IntegrationItem getReferencedItem(java.lang.String attribute)
- Specified by:
getReferencedItemin interfaceIntegrationItem- Parameters:
attribute- name of the attribute, whose value is a nestedIntegrationItem- Returns:
- the referenced item or
null, if this item does not contain the referenced item for the specified attribute name.
-
getReferencedItem
public IntegrationItem getReferencedItem(TypeAttributeDescriptor attribute)
Description copied from interface:IntegrationItemRetrieves an integration item referenced by specified attribute. It does the same as callingIntegrationItem.getAttribute(String)but there is no need to cast result of that call toIntegrationItem.- Specified by:
getReferencedItemin interfaceIntegrationItem- Parameters:
attribute- attribute, whose value is a nestedIntegrationItem- Returns:
- the referenced item or
null, if this item does not contain the referenced item for the specified attribute name.
-
getReferencedItems
public java.util.Collection<IntegrationItem> getReferencedItems(java.lang.String attribute)
- Specified by:
getReferencedItemsin interfaceIntegrationItem- Parameters:
attribute- name of the attribute, whose value is a collection of nestedIntegrationItems- Returns:
- the referenced items. if this item does not contain referenced items for the specified attribute name, an empty
collection is returned. If the attribute references a single instance of an
IntegrationIteminstead of a collection, then a collection with that single item will be returned.
-
getReferencedItems
public java.util.Collection<IntegrationItem> getReferencedItems(TypeAttributeDescriptor attribute)
Description copied from interface:IntegrationItemRetrieves multiple integration items referenced by specified attribute. It does the same as callingIntegrationItem.getAttribute(String)but there is no need to cast result of that call toCollection<IntegrationItem>.- Specified by:
getReferencedItemsin interfaceIntegrationItem- Parameters:
attribute- attribute, whose value is a collection of nestedIntegrationItems- Returns:
- the referenced items. if this item does not contain referenced items for the specified attribute name, an empty
collection is returned. If the attribute references a single instance of an
IntegrationIteminstead of a collection, then a collection with that single item will be returned.
-
setIntegrationKey
public void setIntegrationKey(java.lang.String key)
Sets the integrationKey on this item.- Parameters:
key- integration key of this item. Integration key can benull
-
getContextItem
public java.util.Optional<IntegrationItem> getContextItem(TypeDescriptor contextItemDescriptor)
Description copied from interface:IntegrationItemRetrieves a context item for the given TypeDescriptor if one exists. This search is done recursively through the item's containers until a matching context item is found. If no context item exists,Optional.empty()is returned.- Specified by:
getContextItemin interfaceIntegrationItem- Parameters:
contextItemDescriptor- the type of the context item to find- Returns:
- the requested context item if one exists.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-