Class ClassUtility
java.lang.Object
de.iip_ecosphere.platform.support.iip_aas.ClassUtility
public class ClassUtility extends Object
Utility functions for representing types in AAS. A Java type is turned into
- Submodel: types
- Submodel elements collection: Java type name, inner classes as "."
- Property:
ATTRIBUTE_PREFIX+ attribute name, value = type (for primitives or String) - Submodel elements collection:
ATTRIBUTE_PREFIX+ attribute name- Property/ReferenceElement:
NAME_ARRAY_PROPERTY_TYPE(property for primitives or String, reference element for reference types) - Property
NAME_ARRAY_PROPERTY_DIMENSIONSnumeric number of nested array dimensions
- Property/ReferenceElement:
- ReferenceElement:
ATTRIBUTE_PREFIX+ attribute name, value = ref-to collection (for reference types)
- Property:
- Submodel elements collection: Java type name, inner classes as "."
- Property: attribute1 name, value = type (for primitives, arrays and String)
- ReferenceElement: attribute1 name, value = ref-to collection (for reference types)
Skip will not be listed. So far, arrays over reference types are represented as
strings rather than references to the component type.
The implemented format is initial and will change over time (array of ref type unclear, generics).- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields Modifier and Type Field Description static StringATTRIBUTE_PREFIXprivate static StringJVM_NAMEstatic StringNAME_ARRAY_PROPERTY_DIMENSIONSstatic StringNAME_ARRAY_PROPERTY_TYPEprivate static Map<Class<?>,String>NAME_MAPPINGstatic StringNAME_TYPE_SUBMODEL -
Constructor Summary
Constructors Constructor Description ClassUtility() -
Method Summary
Modifier and Type Method Description static de.iip_ecosphere.platform.support.aas.ReferenceaddType(de.iip_ecosphere.platform.support.aas.Aas.AasBuilder aasBuilder, Class<?> type)Adds a type to an AAS as sub-model.private static de.iip_ecosphere.platform.support.aas.ReferenceaddType(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, Class<?> type)Adds a type to a sub-model.static de.iip_ecosphere.platform.support.aas.SubmodelElementaddTypeSubModelElement(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder subModelBuilder, String idShort, Class<?> type)Adds a type-representing sub-model element.static StringgetId(String prefix, Object object)Turns the object into a unique id with given (optional) prefix.static StringgetName(Class<?> type)Returns the name of the associated model element.private static voidregisterBySimpleName(Class<?> type)Registers atypeby its simple name.private static voidregisterBySimpleName(Class<?> type, Class<?> nameType)Registers atypeby the simple name ofnameType, e.g., to map wrappers to their primitive types.static StringtranslateToAasName(String name)Translates a name to an AAS short name.
-
Field Details
-
NAME_TYPE_SUBMODEL
- See Also:
- Constant Field Values
-
ATTRIBUTE_PREFIX
- See Also:
- Constant Field Values
-
NAME_ARRAY_PROPERTY_TYPE
- See Also:
- Constant Field Values
-
NAME_ARRAY_PROPERTY_DIMENSIONS
- See Also:
- Constant Field Values
-
JVM_NAME
-
NAME_MAPPING
-
-
Constructor Details
-
ClassUtility
public ClassUtility()
-
-
Method Details
-
registerBySimpleName
Registers atypeby its simple name.- Parameters:
type- the type
-
registerBySimpleName
Registers atypeby the simple name ofnameType, e.g., to map wrappers to their primitive types.- Parameters:
type- the typenameType- the type providing the name
-
addType
public static de.iip_ecosphere.platform.support.aas.Reference addType(de.iip_ecosphere.platform.support.aas.Aas.AasBuilder aasBuilder, Class<?> type)Adds a type to an AAS as sub-model. If the type already exists in the AAS/submodel, no new element will be created just a reference to it will be returned. [static data]- Parameters:
aasBuilder- the AAS buildertype- the type to add- Returns:
- the reference to the sub-model (null if nothing was created)
-
addType
private static de.iip_ecosphere.platform.support.aas.Reference addType(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, Class<?> type)Adds a type to a sub-model. [static data]- Parameters:
builder- the target sub-modeltype- the type to add- Returns:
- the reference to the type (null if nothing was created)
-
addTypeSubModelElement
public static de.iip_ecosphere.platform.support.aas.SubmodelElement addTypeSubModelElement(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder subModelBuilder, String idShort, Class<?> type)Adds a type-representing sub-model element. [static data]- Parameters:
subModelBuilder- the target sub-modelidShort- the name of the elementtype- the type to represent in the element- Returns:
- the created sub-model element
-
translateToAasName
Translates a name to an AAS short name.- Parameters:
name- the name- Returns:
- the AAS short name
-
getName
Returns the name of the associated model element.- Parameters:
type- the type- Returns:
- the name
-
getId
Turns the object into a unique id with given (optional) prefix.- Parameters:
prefix- an optional prefix, use an empty string for none; shall end with a separator, e.g., "_"object- the object to be turned into a unique id- Returns:
- the combined id
-