Interface TypeService

All Known Implementing Classes:
DefaultTypeService

public interface TypeService
Service covering type system of the platform. Provides a methods to access TypeModel, DescriptorModel and related objects.
Since:
4.0
Spring Bean ID:
typeService
  • Method Details

    • getComposedType

      @Deprecated(since="ages", forRemoval=true) ComposedTypeModel getComposedType(String code)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages - usegetComposedTypeForCode(String) instead.
      Returns a specific composed type.
      Parameters:
      code - the unique code of this type
      Throws:
      UnknownIdentifierException - if no type exist for this code
    • getComposedTypeForCode

      ComposedTypeModel getComposedTypeForCode(String code)
      Returns the specific composed type for code.
      Parameters:
      code - the unique code of this type code
      Returns:
      the composed type for the specified code
      Throws:
      IllegalArgumentException - thrown when given code is null
      AmbiguousIdentifierException - the ambiguous identifier exception when more than one composed type for given code is found
      UnknownIdentifierException - the unknown identifier exception when no composed type for given code is found
    • getComposedType

      @Deprecated(since="ages", forRemoval=true) ComposedTypeModel getComposedType(Class modelClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages - usegetComposedTypeForClass(Class) instead.
      Returns the composed type for a specified model class.
      Parameters:
      modelClass - the model class
      Throws:
      IllegalArgumentException - if no type is mapped to this model
    • getComposedTypeForClass

      ComposedTypeModel getComposedTypeForClass(Class modelClass)
      Returns the specific composed type for the model class.
      Parameters:
      modelClass - the model class we are looking composed type for
      Returns:
      the composed type for class
      Throws:
      IllegalArgumentException - thrown when given modelClass is null
      UnknownIdentifierException - the unknown identifier exception when no composed type for given modelClass is found
    • getAttributeDescriptor

      AttributeDescriptorModel getAttributeDescriptor(ComposedTypeModel composedType, String qualifier)
      Returns a specific attribute descriptor for a given composed type. This includes declared and inherited attributes.
      Parameters:
      composedType - the composed type to get attribute descriptor for
      qualifier - the attribute qualifier
      Throws:
      UnknownIdentifierException - if the composed type does not own a matching attribute
    • getAttributeDescriptor

      AttributeDescriptorModel getAttributeDescriptor(String composedTypeCode, String qualifier)
      Returns a specific attribute descriptor for a given composed type. This includes declared and inherited attributes.
      Parameters:
      composedTypeCode - the code of the composed type to get attribute descriptor for
      qualifier - the attribute qualifier
      Throws:
      UnknownIdentifierException - if the composed type does not own a matching attribute
    • getAttributeDescriptors

      @Deprecated(since="ages", forRemoval=true) Set<AttributeDescriptorModel> getAttributeDescriptors(ComposedTypeModel composedType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns all attribute descriptors of a single composed type. This includes declared and inherited ones.
      Parameters:
      composedType - the composed type to get attribute descriptors from
    • getAttributeDescriptorsForType

      Set<AttributeDescriptorModel> getAttributeDescriptorsForType(ComposedTypeModel composedType)
      Gets the attribute descriptors for type.
      Parameters:
      composedType - the composed type
      Returns:
      the attribute descriptors for type
      Throws:
      IllegalArgumentException - thrown when given type is null
    • getAttributeDescriptors

      @Deprecated(since="ages", forRemoval=true) Set<AttributeDescriptorModel> getAttributeDescriptors(String composedTypeCode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns all attribute descriptors (as AttributeDescriptorModel) of a single composed type. This includes declared and inherited ones. This also includes attributes which are not generated in the model layer.
      Parameters:
      composedTypeCode - the code of the composed type to get attribute descriptors from
      Throws:
      UnknownIdentifierException - if no matching composed type exists
    • getInitialAttributeDescriptorsForType

      Set<AttributeDescriptorModel> getInitialAttributeDescriptorsForType(ComposedTypeModel composedTypeModel)
      Returns all attribute descriptors of this type which are marked as being initial.

      Initial attributes are normally non-writable attributes intended to be set during item creation only. Therefore having initial and writable attributed does not make much sense.

      Parameters:
      composedTypeModel - the composed type model we look initial attribute descriptors for
      Returns:
      the initial attribute descriptors for the given model
    • getAtomicType

      @Deprecated(since="ages", forRemoval=true) AtomicTypeModel getAtomicType(String code)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages - usegetAtomicTypeForCode(String) instead.
      Returns a specific atomic type.
      Parameters:
      code - the unique code of this type
      Throws:
      UnknownIdentifierException - if no type exist for this code
    • getAtomicTypeForCode

      AtomicTypeModel getAtomicTypeForCode(String code)
      Gets the atomic type for code.
      Parameters:
      code - the code
      Returns:
      the atomic type for code
      Throws:
      IllegalArgumentException - thrown when given code is null
      UnknownIdentifierException - if no type exist for this code
    • getAtomicTypeForJavaClass

      AtomicTypeModel getAtomicTypeForJavaClass(Class javaClass)
      Returns the atomic type for java class.
      Parameters:
      javaClass - the java class that we are looking atomic type for
      Returns:
      the atomic type for java class
      Throws:
      IllegalArgumentException - thrown when given class is null
      UnknownIdentifierException - if no type exist for this class
    • getType

      @Deprecated(since="ages", forRemoval=true) TypeModel getType(String code)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages - usegetTypeForCode(String) instead.
      Returns a specific type. This includes composed, atomic, collection and map types.
      Parameters:
      code - the unique code of this type
      Throws:
      UnknownIdentifierException - if no type exist for this code
    • getTypeForCode

      TypeModel getTypeForCode(String code)
      Returns a specific type. This includes composed, atomic, collection and map types.
      Parameters:
      code - the code for the required type
      Returns:
      the type for code
      Throws:
      UnknownIdentifierException - if no type exist for this code
      IllegalArgumentException - thrown when given code is null
    • getEnumerationType

      @Deprecated(since="ages", forRemoval=true) EnumerationMetaTypeModel getEnumerationType(String code)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages - usegetEnumerationTypeForCode(String) instead.
      Returns a specific enumeration type.
      Parameters:
      code - the unique code of this type
      Throws:
      UnknownIdentifierException - if no type exist for this code
    • getEnumerationTypeForCode

      EnumerationMetaTypeModel getEnumerationTypeForCode(String code)
      Gets the enumeration type for code.
      Parameters:
      code - the code for the required type
      Returns:
      the enumeration type for code
      Throws:
      UnknownIdentifierException - if no type exist for this code
      IllegalArgumentException - thrown when given code is null
    • getEnumerationValue

      EnumerationValueModel getEnumerationValue(String type, String code)
      Returns a specific enumeration value.
      Parameters:
      type - the enumeration type code
      code - the value code
      Throws:
      UnknownIdentifierException - if either no matching enumeration type exists or no value with matching code
      IllegalArgumentException - thrown when given type or code is null
    • getEnumerationValue

      EnumerationValueModel getEnumerationValue(HybrisEnumValue plainEnum)
      Converts a plain enum value into its underlying model.
      Parameters:
      plainEnum - the enum constant
      Throws:
      IllegalArgumentException - thrown when given enum is null
    • getMandatoryAttributes

      Set<String> getMandatoryAttributes(String type, boolean forCreation)
      Provides all mandatory attributes required to save models of the specified type. If the model is new (creation) this method will return initial attributes but omit attributes providing default values. Otherwise initial attributes are omitted but all other mandatory ones are returned no matter if they've got default values or not.
      Parameters:
      type - the type to get attributes for
      forCreation - creation or update
    • getUniqueAttributes

      Set<String> getUniqueAttributes(String type)
      Provides all attributes marked as unique within the given type.
      Parameters:
      type - the type to get unique attributes for
      Returns:
      an empty set if type has no unique attributes
    • getUniqueModelRootType

      String getUniqueModelRootType(String composedtypecode)
      This method finds for the given composedtypecode the root ComposedType which contains/declares the same unique attributes as the given ComposedType. This could be the same typecode or a typecode of any supertype of this ComposedType. The result is returned as typecode String.
      Parameters:
      composedtypecode - any composed type code of the platform
      Returns:
      null if the given ComposedType contains no unique attributes.
      Throws:
      IllegalArgumentException - if no such ComposedType by the given typecode exists
    • getDefaultValues

      Map<String,Object> getDefaultValues(String type)
      Fetches all configured default values for a specified type.
      Parameters:
      type - the type to get default values for
      Returns:
      a map containing all attributes and their default values which have got a configured value
    • getDefaultValues

      Map<String,Object> getDefaultValues(String type, Collection<String> attributes)
      Fetches a subset of all configured default values for a specified type.
      Parameters:
      type - the type to get default values for
      attributes - the attributes to consider
      Returns:
      a map containing all attributes and their default values which have got a configured value
    • isAssignableFrom

      boolean isAssignableFrom(TypeModel superModelType, TypeModel subModelType)
      Returns true if the TypeModel, given by the parameter superModelType, is a super type of the TypeModel OR the same type as the TypeModel, given by the parameter subModelTypeCode.
      Parameters:
      superModelType -
      subModelType -
      Returns:
      true if source type can be assigned to target type
    • isAssignableFrom

      boolean isAssignableFrom(String superModelTypeCode, String subModelTypeCode)
      Returns true if the model type, given by the parameter superModelTypeCode, is a super type of the type of the model OR the same type as the type of the model, given by the parameter subModelTypeCode.
      Parameters:
      superModelTypeCode - - the type code (TypeModel) of the super type
      subModelTypeCode - - the type code (TypeModel) of the sub type
      Returns:
      false if the sub model type is not addignable from the super model type or if any parameter is null
    • isInstance

      boolean isInstance(TypeModel type, Object obj)
      Tests if the given object is an item instance of Type type.
      Parameters:
      type -
      obj -
      Returns:
      true if given object is an item instance of Type type
    • getPartOfAttributes

      Set<String> getPartOfAttributes(String composedTypeCode)
      Provides all attribute qualifiers marked as part-of within the given type.
      Parameters:
      composedTypeCode - the composedType code to get part-of attributes for
      Returns:
      an empty set if type has no part-of attributes
    • hasAttribute

      boolean hasAttribute(ComposedTypeModel type, String qualifier)
      Checks if type has attribute.
      Parameters:
      type - type
      qualifier - qualifier to check
      Returns:
      true if type has attribute
    • getModelClass

      <T extends ItemModel> Class<T> getModelClass(ComposedTypeModel type)
      Returns model class for a type.
      Parameters:
      type - type
      Returns:
      model class for a given type
    • getModelClass

      <T extends ItemModel> Class<T> getModelClass(String typeCode)
      Returns model class for a type code.
      Parameters:
      typeCode - code of a type
      Returns:
      model class for a given type code
    • getAttributesForModifiers

      Set<AttributeDescriptorModel> getAttributesForModifiers(String composedTypeCode, AttributeModifierCriteria criteria)
      Gets the attributes for modifiers for given composed type and criteria container. To add proper criterias to the argument use constants in the class AttributeModifiers.
      Parameters:
      composedTypeCode - the composed type code
      criteria - the criteria
      Returns:
      the attributes for modifiers
    • getRuntimeAttributeDescriptorsForType

      default Collection<AttributeDescriptorModel> getRuntimeAttributeDescriptorsForType(ComposedTypeModel composedType)
      Gets all runtime attributes for a type. A runtime attribute was created from a code and does not have a definition in the *item.xml.
      Parameters:
      composedType - the composed type model model
      Returns:
      runtime attributes
    • isRuntimeAttribute

      default Boolean isRuntimeAttribute(AttributeDescriptorModel attributeDescriptorModel)
      Checks if the attribute descriptor is a runtime one. A runtime attribute was created from a code and does not have a definition in the *item.xml. For attributes marked as dontoptimize it returns false.
      Parameters:
      attributeDescriptorModel - the attribute descriptor model
      Returns:
      true is the attribute is runtime