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 "."
Type usages, e.g., for input/output types are translated to
  • Property: attribute1 name, value = type (for primitives, arrays and String)
  • ReferenceElement: attribute1 name, value = ref-to collection (for reference types)
Attributes marked by 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 Details

  • Constructor Details

    • ClassUtility

      public ClassUtility()
  • Method Details

    • registerBySimpleName

      private static void registerBySimpleName(Class<?> type)
      Registers a type by its simple name.
      Parameters:
      type - the type
    • registerBySimpleName

      private static void registerBySimpleName(Class<?> type, Class<?> nameType)
      Registers a type by the simple name of nameType, e.g., to map wrappers to their primitive types.
      Parameters:
      type - the type
      nameType - 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 builder
      type - 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-model
      type - 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-model
      idShort - the name of the element
      type - the type to represent in the element
      Returns:
      the created sub-model element
    • getName

      public static String getName(Class<?> type)
      Returns the name of the associated model element.
      Parameters:
      type - the type
      Returns:
      the name
    • getId

      public static String getId(String prefix, Object object)
      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