Interface TypeService
-
- All Known Implementing Classes:
DefaultTypeService
public interface TypeService
Service covering type system of the platform. Provides a methods to accessTypeModel
,DescriptorModel
and related objects.- Since:
- 4.0
- Spring Bean ID:
- typeService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description AtomicTypeModel
getAtomicType(java.lang.String code)
Deprecated.since ages - usegetAtomicTypeForCode(String)
instead.AtomicTypeModel
getAtomicTypeForCode(java.lang.String code)
Gets the atomic type for code.AtomicTypeModel
getAtomicTypeForJavaClass(java.lang.Class javaClass)
Returns the atomic type for java class.AttributeDescriptorModel
getAttributeDescriptor(ComposedTypeModel composedType, java.lang.String qualifier)
Returns a specific attribute descriptor for a given composed type.AttributeDescriptorModel
getAttributeDescriptor(java.lang.String composedTypeCode, java.lang.String qualifier)
Returns a specific attribute descriptor for a given composed type.java.util.Set<AttributeDescriptorModel>
getAttributeDescriptors(ComposedTypeModel composedType)
Deprecated.since ages - - usegetAttributeDescriptorsForType(ComposedTypeModel)
instead.java.util.Set<AttributeDescriptorModel>
getAttributeDescriptors(java.lang.String composedTypeCode)
Deprecated.since ages - usegetAttributeDescriptorsForType(ComposedTypeModel)
instead.java.util.Set<AttributeDescriptorModel>
getAttributeDescriptorsForType(ComposedTypeModel composedType)
Gets the attribute descriptors for type.java.util.Set<AttributeDescriptorModel>
getAttributesForModifiers(java.lang.String composedTypeCode, AttributeModifierCriteria criteria)
Gets the attributes for modifiers for given composed type and criteria container.ComposedTypeModel
getComposedType(java.lang.Class modelClass)
Deprecated.since ages - usegetComposedTypeForClass(Class)
instead.ComposedTypeModel
getComposedType(java.lang.String code)
Deprecated.since ages - usegetComposedTypeForCode(String)
instead.ComposedTypeModel
getComposedTypeForClass(java.lang.Class modelClass)
Returns the specific composed type for the model class.ComposedTypeModel
getComposedTypeForCode(java.lang.String code)
Returns the specific composed type for code.java.util.Map<java.lang.String,java.lang.Object>
getDefaultValues(java.lang.String type)
Fetches all configured default values for a specified type.java.util.Map<java.lang.String,java.lang.Object>
getDefaultValues(java.lang.String type, java.util.Collection<java.lang.String> attributes)
Fetches a subset of all configured default values for a specified type.EnumerationMetaTypeModel
getEnumerationType(java.lang.String code)
Deprecated.since ages - usegetEnumerationTypeForCode(String)
instead.EnumerationMetaTypeModel
getEnumerationTypeForCode(java.lang.String code)
Gets the enumeration type for code.EnumerationValueModel
getEnumerationValue(HybrisEnumValue plainEnum)
Converts a plain enum value into its underlying model.EnumerationValueModel
getEnumerationValue(java.lang.String type, java.lang.String code)
Returns a specific enumeration value.java.util.Set<AttributeDescriptorModel>
getInitialAttributeDescriptorsForType(ComposedTypeModel composedTypeModel)
Returns all attribute descriptors of this type which are marked as being initial.java.util.Set<java.lang.String>
getMandatoryAttributes(java.lang.String type, boolean forCreation)
Provides all mandatory attributes required to save models of the specified type.<T extends ItemModel>
java.lang.Class<T>getModelClass(ComposedTypeModel type)
Returns model class for a type.<T extends ItemModel>
java.lang.Class<T>getModelClass(java.lang.String typeCode)
Returns model class for a type code.java.util.Set<java.lang.String>
getPartOfAttributes(java.lang.String composedTypeCode)
Provides all attribute qualifiers marked as part-of within the given type.TypeModel
getType(java.lang.String code)
Deprecated.since ages - usegetTypeForCode(String)
instead.TypeModel
getTypeForCode(java.lang.String code)
Returns a specific type.java.util.Set<java.lang.String>
getUniqueAttributes(java.lang.String type)
Provides all attributes marked as unique within the given type.java.lang.String
getUniqueModelRootType(java.lang.String composedtypecode)
This method finds for the givencomposedtypecode
the root ComposedType which contains/declares the same unique attributes as the given ComposedType.boolean
hasAttribute(ComposedTypeModel type, java.lang.String qualifier)
Checks if type has attribute.boolean
isAssignableFrom(TypeModel superModelType, TypeModel subModelType)
boolean
isAssignableFrom(java.lang.String superModelTypeCode, java.lang.String subModelTypeCode)
Returnstrue
if the model type, given by the parametersuperModelTypeCode
, is a super type of the type of the model OR the same type as the type of the model, given by the parametersubModelTypeCode
.boolean
isInstance(TypeModel type, java.lang.Object obj)
Tests if the given object is an item instance of Type type.
-
-
-
Method Detail
-
getComposedType
@Deprecated ComposedTypeModel getComposedType(java.lang.String code)
Deprecated.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(java.lang.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:
java.lang.IllegalArgumentException
- thrown when given code is nullAmbiguousIdentifierException
- the ambiguous identifier exception when more than one composed type for given code is foundUnknownIdentifierException
- the unknown identifier exception when no composed type for given code is found
-
getComposedType
@Deprecated ComposedTypeModel getComposedType(java.lang.Class modelClass)
Deprecated.since ages - usegetComposedTypeForClass(Class)
instead.Returns the composed type for a specified model class.- Parameters:
modelClass
- the model class- Throws:
java.lang.IllegalArgumentException
- if no type is mapped to this model
-
getComposedTypeForClass
ComposedTypeModel getComposedTypeForClass(java.lang.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:
java.lang.IllegalArgumentException
- thrown when given modelClass is nullUnknownIdentifierException
- the unknown identifier exception when no composed type for given modelClass is found
-
getAttributeDescriptor
AttributeDescriptorModel getAttributeDescriptor(ComposedTypeModel composedType, java.lang.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 forqualifier
- the attribute qualifier- Throws:
UnknownIdentifierException
- if the composed type does not own a matching attribute
-
getAttributeDescriptor
AttributeDescriptorModel getAttributeDescriptor(java.lang.String composedTypeCode, java.lang.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 forqualifier
- the attribute qualifier- Throws:
UnknownIdentifierException
- if the composed type does not own a matching attribute
-
getAttributeDescriptors
@Deprecated java.util.Set<AttributeDescriptorModel> getAttributeDescriptors(ComposedTypeModel composedType)
Deprecated.since ages - - usegetAttributeDescriptorsForType(ComposedTypeModel)
instead.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
java.util.Set<AttributeDescriptorModel> getAttributeDescriptorsForType(ComposedTypeModel composedType)
Gets the attribute descriptors for type.- Parameters:
composedType
- the composed type- Returns:
- the attribute descriptors for type
- Throws:
java.lang.IllegalArgumentException
- thrown when given type is null
-
getAttributeDescriptors
@Deprecated java.util.Set<AttributeDescriptorModel> getAttributeDescriptors(java.lang.String composedTypeCode)
Deprecated.since ages - usegetAttributeDescriptorsForType(ComposedTypeModel)
instead.Returns all attribute descriptors (asAttributeDescriptorModel
) 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
java.util.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 AtomicTypeModel getAtomicType(java.lang.String code)
Deprecated.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(java.lang.String code)
Gets the atomic type for code.- Parameters:
code
- the code- Returns:
- the atomic type for code
- Throws:
java.lang.IllegalArgumentException
- thrown when given code is nullUnknownIdentifierException
- if no type exist for this code
-
getAtomicTypeForJavaClass
AtomicTypeModel getAtomicTypeForJavaClass(java.lang.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:
java.lang.IllegalArgumentException
- thrown when given class is nullUnknownIdentifierException
- if no type exist for this class
-
getType
@Deprecated TypeModel getType(java.lang.String code)
Deprecated.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(java.lang.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 codejava.lang.IllegalArgumentException
- thrown when given code is null
-
getEnumerationType
@Deprecated EnumerationMetaTypeModel getEnumerationType(java.lang.String code)
Deprecated.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(java.lang.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 codejava.lang.IllegalArgumentException
- thrown when given code is null
-
getEnumerationValue
EnumerationValueModel getEnumerationValue(java.lang.String type, java.lang.String code)
Returns a specific enumeration value.- Parameters:
type
- the enumeration type codecode
- the value code- Throws:
UnknownIdentifierException
- if either no matching enumeration type exists or no value with matching codejava.lang.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:
java.lang.IllegalArgumentException
- thrown when given enum is null
-
getMandatoryAttributes
java.util.Set<java.lang.String> getMandatoryAttributes(java.lang.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 forforCreation
- creation or update
-
getUniqueAttributes
java.util.Set<java.lang.String> getUniqueAttributes(java.lang.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
java.lang.String getUniqueModelRootType(java.lang.String composedtypecode)
This method finds for the givencomposedtypecode
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:
java.lang.IllegalArgumentException
- if no such ComposedType by the given typecode exists
-
getDefaultValues
java.util.Map<java.lang.String,java.lang.Object> getDefaultValues(java.lang.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
java.util.Map<java.lang.String,java.lang.Object> getDefaultValues(java.lang.String type, java.util.Collection<java.lang.String> attributes)
Fetches a subset of all configured default values for a specified type.- Parameters:
type
- the type to get default values forattributes
- 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)
Returnstrue
if theTypeModel
, given by the parametersuperModelType
, is a super type of theTypeModel
OR the same type as theTypeModel
, given by the parametersubModelTypeCode
.- Parameters:
superModelType
-subModelType
-- Returns:
true
if source type can be assigned to target type
-
isAssignableFrom
boolean isAssignableFrom(java.lang.String superModelTypeCode, java.lang.String subModelTypeCode)
Returnstrue
if the model type, given by the parametersuperModelTypeCode
, is a super type of the type of the model OR the same type as the type of the model, given by the parametersubModelTypeCode
.
-
isInstance
boolean isInstance(TypeModel type, java.lang.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
java.util.Set<java.lang.String> getPartOfAttributes(java.lang.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, java.lang.String qualifier)
Checks if type has attribute.- Parameters:
type
- typequalifier
- qualifier to check- Returns:
- true if type has attribute
-
getModelClass
<T extends ItemModel> java.lang.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> java.lang.Class<T> getModelClass(java.lang.String typeCode)
Returns model class for a type code.- Parameters:
typeCode
- code of a type- Returns:
- model class for a given type code
-
getAttributesForModifiers
java.util.Set<AttributeDescriptorModel> getAttributesForModifiers(java.lang.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 classAttributeModifiers
.- Parameters:
composedTypeCode
- the composed type codecriteria
- the criteria- Returns:
- the attributes for modifiers
-
-