Interface TypeDescriptor
- All Known Implementing Classes:
ItemTypeDescriptor,MapTypeDescriptor,PrimitiveTypeDescriptor
public interface TypeDescriptor
Describes platform type in the context of an integration object item type. It may represent type of an integration object item
or a primitive, or other types, which integration object item attributes may have.
This metadata can be used for converting a custom payload to and from the platform's
ItemModel-
Method Summary
Modifier and TypeMethodDescription@NotNull Optional<TypeAttributeDescriptor>getAttribute(String attrName) Retrieves descriptor of the specified attribute.@NotNull Collection<TypeAttributeDescriptor>Retrieves all attributes defined in an integration object item.@NotNull StringReads value of the integration object code.@NotNull StringReads value of the integration object item code.Retrieves key descriptor of this item type.Retrieves attribute path from this item type to the root item type in the same integration object.@NotNull StringReads code (name) of the integration object item type in the type system.booleanDetermines whether it's possible to navigate from an integration item described by this type descriptor to the root item of the integration object.booleanDetermines whether this descriptor is an abstract item typebooleanDetermines whether this descriptor is for a type representing type system enumeration.booleanisInstance(Object obj) Determines whether the specified object is an instance of the type presented by this type descriptor.default booleanisMap()Determines whether this descriptor is for a type representing integration object item or for a map type.booleanDetermines whether this descriptor is for type representing integration object item or for a primitive type.booleanisRoot()Determines whether this descriptor is for the root item in the Integration Objectdefault List<ReferencePath>pathFrom(TypeDescriptor itemType) Retrieves attribute path from the specified item type to this item type.
-
Method Details
-
getIntegrationObjectCode
Reads value of the integration object code.- Returns:
- integration object code this item belongs to.
-
getItemCode
Reads value of the integration object item code.- Returns:
- integration object item type code. Keep in mind this value may be different from the type code of the item the integration object item represents. For example, type code of the item in the platform may be "Product" but integration object item type could be called "IntegrationProduct".
- See Also:
-
getTypeCode
Reads code (name) of the integration object item type in the type system.- Returns:
- type code of the item in the type system. Keep in mind this value may be different from the integration objec item code. For example, type code of the item in the type system may be "Product" but integration object item code may be different, e.g "IntegrationProduct".
- See Also:
-
getAttribute
Retrieves descriptor of the specified attribute.- Parameters:
attrName- name of the integration object item attribute to be retrieved. Keep in mind that name of the attribute in an integration object item may be different from the name of the corresponding attribute in the type system.- Returns:
- attribute descriptor for the given name or
Optional.empty(), if the item type does not have an attribute with such name.
-
getAttributes
Retrieves all attributes defined in an integration object item.- Returns:
- a collection of all attributes in the integration object item or an empty collection, if this description is for a primitive type or the item does not have attributes.
-
isPrimitive
boolean isPrimitive()Determines whether this descriptor is for type representing integration object item or for a primitive type.- Returns:
true, if this descriptor is for a primitive type, e.g. Integer, String, etc;false, otherwise.
-
isMap
default boolean isMap()Determines whether this descriptor is for a type representing integration object item or for a map type.- Returns:
true, if this descriptor is for a map type;false, otherwise.
-
isEnumeration
boolean isEnumeration()Determines whether this descriptor is for a type representing type system enumeration.- Returns:
true, if this descriptor is for an enumeration type;falseotherwise.
-
isAbstract
boolean isAbstract()Determines whether this descriptor is an abstract item type- Returns:
true, if the item type of this descriptor hasabstract == true
-
isInstance
Determines whether the specified object is an instance of the type presented by this type descriptor.- Parameters:
obj- an object to evaluate.- Returns:
true, if the specified object is an instance of the type presented by this type descriptor;false, if the object isnullor cannot be described by this type descriptor.
-
isRoot
boolean isRoot()Determines whether this descriptor is for the root item in the Integration Object- Returns:
true, if this descriptor is the root;falseotherwise.
-
getKeyDescriptor
KeyDescriptor getKeyDescriptor()Retrieves key descriptor of this item type.- Returns:
- descriptor of the key identifying instances of this item type.
-
getPathsToRoot
List<ReferencePath> getPathsToRoot()Retrieves attribute path from this item type to the root item type in the same integration object.- Returns:
- a list of all possible paths in order from the shorter ones to the longer paths. If this type descriptor does not contain attribute(s) that eventually lead to the root item type, then an empty list is returned.
- See Also:
-
hasPathToRoot
boolean hasPathToRoot()Determines whether it's possible to navigate from an integration item described by this type descriptor to the root item of the integration object.- Returns:
true, if this type descriptor describes a root item type in the integration object or it has aReferencePathto the root item type.- See Also:
-
pathFrom
Retrieves attribute path from the specified item type to this item type. For example, if there is an integration object:Product - catalogVersion -> CatalogVersion - catalog -> Catalog - id - categories -> Category - catalogVersion -> CatalogVersion - catalog -> Catalog - idwhere Product, Category, CatalogVersion and Catalog are integration object items and catalogVersion, categories, catalog and id are the attributes in the corresponding items. If current type descriptor is for Catalog type and the Product type descriptor is passed, then the paths are:Product.catalogVersion.catalogandProduct.categories.catalogVersion.catalog.- Parameters:
itemType- descriptor of the item type, from which the path has to be calculated.- Returns:
- all paths from the specified type to the type described this descriptor in order from the shortest to the longest path or an empty list, if this type descriptor and the specified item type are not related, ie. there is no a single path.
-