Class Tools

java.lang.Object
de.iip_ecosphere.platform.support.aas.basyx.Tools

public class Tools
extends Object
Some utilities, such as for parameter checking. Public for testing.
Author:
Holger Eichelberger, SSE
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private static Map<de.iip_ecosphere.platform.support.aas.AssetKind,​org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind> ASSETKINDS2BASYX  
    private static Map<org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind,​de.iip_ecosphere.platform.support.aas.AssetKind> BASYX2ASSETKINDS  
    private static Map<org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef,​de.iip_ecosphere.platform.support.aas.Type> BASYX2TYPES  
    private static Map<de.iip_ecosphere.platform.support.aas.Type,​org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef> TYPES2BASYX  
  • Constructor Summary

    Constructors 
    Constructor Description
    Tools()  
  • Method Summary

    Modifier and Type Method Description
    static String checkId​(String idShort)
    Checks a given short id for not being empty.
    static String checkUrn​(String urn)
    Checks a given URN for not being empty.
    (package private) static void disposeTomcatWorkingDir​(File baseDir, int port)
    Tries to dispose a Tomcat working directory.
    static <E extends Enum<E>>
    E
    getOption​(String[] options, E dflt, Class<E> cls)
    Tests the values in pptions against the constants in cls and returns a matching constant or dflt.
    (package private) static String idToUrlPath​(String id)
    Turns an id into a URL path.
    private static void mapKind​(de.iip_ecosphere.platform.support.aas.AssetKind kind, org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind basyxKind)
    Maps an implementation-independent asset kind into a BaSyx asset kind.
    private static void mapType​(de.iip_ecosphere.platform.support.aas.Type type, org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef basyxType)
    Maps an implementation-independent type into a BaSyx property-value type.
    static org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind translate​(de.iip_ecosphere.platform.support.aas.AssetKind kind)
    Translates a implementation-independent asset kind to an implementation-specific asset kind.
    static org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef translate​(de.iip_ecosphere.platform.support.aas.Type type)
    Translates a implementation-independent type to an implementation-specific type.
    static de.iip_ecosphere.platform.support.aas.AssetKind translate​(org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind kind)
    Translates a implementation-specific asset kind to an implementation-independent asset kind.
    static de.iip_ecosphere.platform.support.aas.Type translate​(org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef type)
    Translates a implementation-specific type to an implementation-independent type.
    static org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier translateIdentifier​(String id, String dfltCustom)
    Translates an identifier.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TYPES2BASYX

      private static final Map<de.iip_ecosphere.platform.support.aas.Type,​org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef> TYPES2BASYX
    • BASYX2TYPES

      private static final Map<org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef,​de.iip_ecosphere.platform.support.aas.Type> BASYX2TYPES
    • ASSETKINDS2BASYX

      private static final Map<de.iip_ecosphere.platform.support.aas.AssetKind,​org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind> ASSETKINDS2BASYX
    • BASYX2ASSETKINDS

      private static final Map<org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind,​de.iip_ecosphere.platform.support.aas.AssetKind> BASYX2ASSETKINDS
  • Constructor Details

  • Method Details

    • mapType

      private static void mapType​(de.iip_ecosphere.platform.support.aas.Type type, org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef basyxType)
      Maps an implementation-independent type into a BaSyx property-value type.
      Parameters:
      type - the implementation-independent type
      basyxType - the corresponding BaSyx property-value type
    • mapKind

      private static void mapKind​(de.iip_ecosphere.platform.support.aas.AssetKind kind, org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind basyxKind)
      Maps an implementation-independent asset kind into a BaSyx asset kind.
      Parameters:
      kind - the implementation-independent asset kind
      basyxKind - the corresponding BaSyx asset kind
    • checkUrn

      public static String checkUrn​(String urn)
      Checks a given URN for not being empty.
      Parameters:
      urn - the URN
      Returns:
      urn
      Throws:
      IllegalArgumentException - if the urn is empty or null
    • checkId

      public static String checkId​(String idShort)
      Checks a given short id for not being empty.
      Parameters:
      idShort - the short id
      Returns:
      idShort
      Throws:
      IllegalArgumentException - if the id is empty or null
    • translate

      public static org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef translate​(de.iip_ecosphere.platform.support.aas.Type type)
      Translates a implementation-independent type to an implementation-specific type.
      Parameters:
      type - the implementation-independent type
      Returns:
      the implementation-specific type
    • translate

      public static de.iip_ecosphere.platform.support.aas.Type translate​(org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDef type)
      Translates a implementation-specific type to an implementation-independent type.
      Parameters:
      type - the implementation-specific type
      Returns:
      the implementation-independent type
    • translate

      public static org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind translate​(de.iip_ecosphere.platform.support.aas.AssetKind kind)
      Translates a implementation-independent asset kind to an implementation-specific asset kind.
      Parameters:
      kind - the implementation-independent asset kind
      Returns:
      the implementation-specific asset kind
    • translate

      public static de.iip_ecosphere.platform.support.aas.AssetKind translate​(org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind kind)
      Translates a implementation-specific asset kind to an implementation-independent asset kind.
      Parameters:
      kind - the implementation-specific asset kind
      Returns:
      the implementation-independent asset kind
    • idToUrlPath

      static String idToUrlPath​(String id)
      Turns an id into a URL path.
      Parameters:
      id - the id
      Returns:
      the URL path
    • translateIdentifier

      public static org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier translateIdentifier​(String id, String dfltCustom)
      Translates an identifier.
      Parameters:
      id - the id showing some form of type, e.g., prefix "urn:", may be empty or null leading to a custom identifier based on dfltCustom
      dfltCustom - the default value if id cannot be used
      Returns:
      the identifier
    • getOption

      public static <E extends Enum<E>> E getOption​(String[] options, E dflt, Class<E> cls)
      Tests the values in pptions against the constants in cls and returns a matching constant or dflt.
      Type Parameters:
      E - the enum type
      Parameters:
      options - the options to check
      dflt - the default value
      cls - the enum class providing the constants
      Returns:
      the matching option or dflt
    • disposeTomcatWorkingDir

      static void disposeTomcatWorkingDir​(File baseDir, int port)
      Tries to dispose a Tomcat working directory.
      Parameters:
      baseDir - the basic directory where the working directory is located in, may be null for default, i.e., program home directory
      port - the port number of the disposed Tomcat instance