java.lang.Object
com.dassault_systemes.modeler.kerml.model.Metadata

@OpenApiAll public class Metadata extends Object
Utility class to work with MetadataFeature or Metaclass.
  • Constructor Details

    • Metadata

      public Metadata()
  • Method Details

    • getOwnedSemanticMetadata

      public static List<MetadataFeature> getOwnedSemanticMetadata(Element element)
      Returns semantic metadata applied to the given Element.
      Parameters:
      element - element
      Returns:
      semantic metadata
    • getMetadata

      public static List<MetadataFeature> getMetadata(Element element)
      Returns all metadata applied to the given Element.
      Parameters:
      element - element
      Returns:
      metadata
    • getMetadataWithSelf

      public static List<MetadataFeature> getMetadataWithSelf(Element element)
      Returns all metadata applied to the given Element including also "self" metadata.
      Parameters:
      element - element
      Returns:
      metadata
    • getOwnedMetadata

      public static List<MetadataFeature> getOwnedMetadata(Element element)
      Returns owned metadata applied to the given Element.
      Parameters:
      element - element
      Returns:
      metadata
    • createOwnedMetadata

      public static MetadataFeature createOwnedMetadata(Element element, Metaclass metaclass)
      Creates and applies owned metadata for a given Element
      Parameters:
      element - element
      metaclass - metaclass of metadata to apply
      Returns:
      created metadata
    • createMetadata

      public static MetadataFeature createMetadata(Element element, Namespace owner, Metaclass metaclass)
      Creates metadata inside given Namespace and applies it for a given Element
      Parameters:
      element - element
      owner - owner of created metadata
      metaclass - metaclass of metadata to apply
      Returns:
      created metadata
    • getOrCreateOwnedMetadata

      public static MetadataFeature getOrCreateOwnedMetadata(Element element, Metaclass metaclass)
      Looks for owned metadata matching given metaclass or creates and applies a new one.
      Parameters:
      element - element
      metaclass - metaclass of metadata to apply
      Returns:
      metadata
      See Also:
    • getMetadata

      @CheckForNull public static MetadataFeature getMetadata(Element element, Metaclass metaclass)
      Returns metadata applied to the element matching the given metaclass.
      Parameters:
      element - element
      metaclass - metaclass to match
      Returns:
      matching metadata, or null
    • getOwnedMetadata

      @CheckForNull public static MetadataFeature getOwnedMetadata(Element element, Metaclass metaclass)
      Returns owned metadata applied to the element matching the given metaclass.
      Parameters:
      element - element
      metaclass - metaclass to match
      Returns:
      matching metadata, or null
    • getMetadata

      @CheckForNull public static MetadataFeature getMetadata(Collection<MetadataFeature> metadata, Metaclass metaclass)
      Returns metadata from the given collection matching the given metaclass.
      Parameters:
      metadata - metadata collection
      metaclass - metaclass to match
      Returns:
      matching metadata, or null
    • setOwnedMetadata

      public static void setOwnedMetadata(Element element, Collection<Metaclass> metaclasses, boolean disposeNotMatching)
      Sets owned metadata of Element matching given metaclasses.
      Parameters:
      element - element
      metaclasses - metaclasses
      disposeNotMatching - disposes existing owned metadata not matching given metaclasses
    • getMetaclassesOfOwnedMetadata

      public static List<Metaclass> getMetaclassesOfOwnedMetadata(Element element)
      Returns metaclasses of owned metadata applied to the element.
      Parameters:
      element - element
      Returns:
      list of metaclasses
    • getMetaclassesOfMetadata

      public static List<Metaclass> getMetaclassesOfMetadata(Element element)
      Returns metaclasses of all metadata applied to the element.
      Parameters:
      element - element
      Returns:
      list of metaclasses
    • mapMetadataToMetaclasses

      public static List<Metaclass> mapMetadataToMetaclasses(List<MetadataFeature> metadataFeatures)
      Maps metadata features to their metaclasses.
      Parameters:
      metadataFeatures - metadata features
      Returns:
      list of metaclasses
    • getAnnotatedElementTypes

      public static List<Metaclass> getAnnotatedElementTypes(MetadataFeature metadataFeature)
      Returns the annotated element types for the given metadata feature.
      Parameters:
      metadataFeature - metadata feature
      Returns:
      list of annotated element types
    • getBaseTypes

      public static List<Type> getBaseTypes(Type target)
      Returns base types associated with metadata applied to the given type.
      Parameters:
      target - type
      Returns:
      list of base types
    • toClassifiers

      public static List<Type> toClassifiers(List<Type> baseType)
      Converts base types to classifiers by expanding feature types.
      Parameters:
      baseType - list of types
      Returns:
      list of classifier types
    • toFeatures

      public static List<Type> toFeatures(List<Type> baseType)
      Filters the given list of types to only those that are features.
      Parameters:
      baseType - list of types
      Returns:
      list containing only feature types
    • getMetaclassName

      @CheckForNull public static String getMetaclassName(MetadataFeature feature)
      Returns the name of the metaclass of the given metadata feature.
      Parameters:
      feature - metadata feature
      Returns:
      metaclass name, or null
    • getMetaclassName

      @CheckForNull public static String getMetaclassName(Metaclass metaclass)
      Returns the name of the given metaclass.
      Parameters:
      metaclass - metaclass
      Returns:
      short name or name, or null
    • isApplicable

      public static boolean isApplicable(Element element)
      Checks whether metadata is applicable to the given element.
      Parameters:
      element - element
      Returns:
      true if metadata can be applied
    • getSelfMetadata

      @CheckForNull public static MetadataFeature getSelfMetadata(Element element)
      Returns the self metadata feature of the element, if any.
      Parameters:
      element - element
      Returns:
      self metadata, or null
    • isSelfMetadata

      public static boolean isSelfMetadata(MetadataFeature metadataFeature)
      Checks whether the given metadata feature is self metadata.
      Parameters:
      metadataFeature - metadata feature
      Returns:
      true if it is self metadata
    • getEClassIfSelfMetadata

      @CheckForNull public static org.eclipse.emf.ecore.EClass getEClassIfSelfMetadata(MetadataFeature metadataFeature)
      Returns the EClass of the syntax element for self metadata.
      Parameters:
      metadataFeature - metadata feature
      Returns:
      EClass of syntax element, or null
    • getMetaClassOf

      @CheckForNull public static Metaclass getMetaClassOf(Element element)
      Returns the metaclass of the given element.
      Parameters:
      element - element
      Returns:
      metaclass, or null
    • getMetaClassFor

      @CheckForNull public static Metaclass getMetaClassFor(ModelElementProject project, org.eclipse.emf.ecore.EClass eClass)
      Returns the metaclass corresponding to the given EClass.
      Parameters:
      project - project
      eClass - EClass
      Returns:
      metaclass, or null
    • getEClassFor

      @CheckForNull public static org.eclipse.emf.ecore.EClass getEClassFor(Metaclass metaclass)
      Returns the EClass corresponding to the given metaclass.
      Parameters:
      metaclass - metaclass
      Returns:
      EClass, or null
    • isMetamodelFeature

      public static boolean isMetamodelFeature(Feature feature)
      Checks whether the given feature is a metamodel feature.
      Parameters:
      feature - feature
      Returns:
      true if the feature belongs to a metaclass with a resolvable EClass
    • isAnnotatedWithOwnedMetadata

      public static boolean isAnnotatedWithOwnedMetadata(Element element, Metaclass metaclass)
      Checks whether the element is annotated with owned metadata of the given metaclass.
      Parameters:
      element - element
      metaclass - metaclass
      Returns:
      true if matching owned metadata exists
    • isInstanceOfMetamodelMetaclass

      public static boolean isInstanceOfMetamodelMetaclass(Element element, Collection<Metaclass> metaclasses)
      Checks whether the element is an instance of the given metamodel metaclasses.
      Parameters:
      element - element
      metaclasses - metaclasses
      Returns:
      true if the element matches any metaclass
    • isInstanceOfMetamodelMetaclass

      public static boolean isInstanceOfMetamodelMetaclass(Element element, Metaclass metaclass)
      Checks whether the element is an instance of the given metamodel metaclass.
      Parameters:
      element - element
      metaclass - metaclass
      Returns:
      true if the element matches the metaclass