Class Metadata
java.lang.Object
com.dassault_systemes.modeler.kerml.model.Metadata
Utility class to work with
MetadataFeature or Metaclass.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MetadataFeaturecreateMetadata(Element element, Namespace owner, Metaclass metaclass) static MetadataFeaturecreateOwnedMetadata(Element element, Metaclass metaclass) Creates and applies owned metadata for a givenElementgetAnnotatedElementTypes(MetadataFeature metadataFeature) Returns the annotated element types for the given metadata feature.getBaseTypes(Type target) Returns base types associated with metadata applied to the given type.static org.eclipse.emf.ecore.EClassgetEClassFor(Metaclass metaclass) Returns the EClass corresponding to the given metaclass.static org.eclipse.emf.ecore.EClassgetEClassIfSelfMetadata(MetadataFeature metadataFeature) Returns the EClass of the syntax element for self metadata.getMetaclassesOfMetadata(Element element) Returns metaclasses of all metadata applied to the element.getMetaclassesOfOwnedMetadata(Element element) Returns metaclasses of owned metadata applied to the element.static MetaclassgetMetaClassFor(ModelElementProject project, org.eclipse.emf.ecore.EClass eClass) Returns the metaclass corresponding to the given EClass.static StringgetMetaclassName(Metaclass metaclass) Returns the name of the given metaclass.static StringgetMetaclassName(MetadataFeature feature) Returns the name of the metaclass of the given metadata feature.static MetaclassgetMetaClassOf(Element element) Returns the metaclass of the given element.static List<MetadataFeature> getMetadata(Element element) Returns all metadata applied to the givenElement.static MetadataFeaturegetMetadata(Element element, Metaclass metaclass) Returns metadata applied to the element matching the given metaclass.static MetadataFeaturegetMetadata(Collection<MetadataFeature> metadata, Metaclass metaclass) Returns metadata from the given collection matching the given metaclass.static List<MetadataFeature> getMetadataWithSelf(Element element) Returns all metadata applied to the givenElementincluding also "self" metadata.static MetadataFeaturegetOrCreateOwnedMetadata(Element element, Metaclass metaclass) Looks for owned metadata matching given metaclass or creates and applies a new one.static List<MetadataFeature> getOwnedMetadata(Element element) Returns owned metadata applied to the givenElement.static MetadataFeaturegetOwnedMetadata(Element element, Metaclass metaclass) Returns owned metadata applied to the element matching the given metaclass.static List<MetadataFeature> getOwnedSemanticMetadata(Element element) Returns semantic metadata applied to the givenElement.static MetadataFeaturegetSelfMetadata(Element element) Returns the self metadata feature of the element, if any.static booleanisAnnotatedWithOwnedMetadata(Element element, Metaclass metaclass) Checks whether the element is annotated with owned metadata of the given metaclass.static booleanisApplicable(Element element) Checks whether metadata is applicable to the given element.static booleanisInstanceOfMetamodelMetaclass(Element element, Metaclass metaclass) Checks whether the element is an instance of the given metamodel metaclass.static booleanisInstanceOfMetamodelMetaclass(Element element, Collection<Metaclass> metaclasses) Checks whether the element is an instance of the given metamodel metaclasses.static booleanisMetamodelFeature(Feature feature) Checks whether the given feature is a metamodel feature.static booleanisSelfMetadata(MetadataFeature metadataFeature) Checks whether the given metadata feature is self metadata.mapMetadataToMetaclasses(List<MetadataFeature> metadataFeatures) Maps metadata features to their metaclasses.static voidsetOwnedMetadata(Element element, Collection<Metaclass> metaclasses, boolean disposeNotMatching) Sets owned metadata ofElementmatching given metaclasses.toClassifiers(List<Type> baseType) Converts base types to classifiers by expanding feature types.toFeatures(List<Type> baseType) Filters the given list of types to only those that are features.
-
Constructor Details
-
Metadata
public Metadata()
-
-
Method Details
-
getOwnedSemanticMetadata
Returns semantic metadata applied to the givenElement.- Parameters:
element- element- Returns:
- semantic metadata
-
getMetadata
Returns all metadata applied to the givenElement.- Parameters:
element- element- Returns:
- metadata
-
getMetadataWithSelf
Returns all metadata applied to the givenElementincluding also "self" metadata.- Parameters:
element- element- Returns:
- metadata
-
getOwnedMetadata
Returns owned metadata applied to the givenElement.- Parameters:
element- element- Returns:
- metadata
-
createOwnedMetadata
Creates and applies owned metadata for a givenElement- Parameters:
element- elementmetaclass- metaclass of metadata to apply- Returns:
- created metadata
-
createMetadata
- Parameters:
element- elementowner- owner of created metadatametaclass- metaclass of metadata to apply- Returns:
- created metadata
-
getOrCreateOwnedMetadata
Looks for owned metadata matching given metaclass or creates and applies a new one.- Parameters:
element- elementmetaclass- metaclass of metadata to apply- Returns:
- metadata
- See Also:
-
getMetadata
Returns metadata applied to the element matching the given metaclass.- Parameters:
element- elementmetaclass- metaclass to match- Returns:
- matching metadata, or null
-
getOwnedMetadata
Returns owned metadata applied to the element matching the given metaclass.- Parameters:
element- elementmetaclass- 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 collectionmetaclass- metaclass to match- Returns:
- matching metadata, or null
-
setOwnedMetadata
public static void setOwnedMetadata(Element element, Collection<Metaclass> metaclasses, boolean disposeNotMatching) Sets owned metadata ofElementmatching given metaclasses.- Parameters:
element- elementmetaclasses- metaclassesdisposeNotMatching- disposes existing owned metadata not matching given metaclasses
-
getMetaclassesOfOwnedMetadata
Returns metaclasses of owned metadata applied to the element.- Parameters:
element- element- Returns:
- list of metaclasses
-
getMetaclassesOfMetadata
Returns metaclasses of all metadata applied to the element.- Parameters:
element- element- Returns:
- list of metaclasses
-
mapMetadataToMetaclasses
Maps metadata features to their metaclasses.- Parameters:
metadataFeatures- metadata features- Returns:
- list of metaclasses
-
getAnnotatedElementTypes
Returns the annotated element types for the given metadata feature.- Parameters:
metadataFeature- metadata feature- Returns:
- list of annotated element types
-
getBaseTypes
Returns base types associated with metadata applied to the given type.- Parameters:
target- type- Returns:
- list of base types
-
toClassifiers
Converts base types to classifiers by expanding feature types.- Parameters:
baseType- list of types- Returns:
- list of classifier types
-
toFeatures
Filters the given list of types to only those that are features.- Parameters:
baseType- list of types- Returns:
- list containing only feature types
-
getMetaclassName
Returns the name of the metaclass of the given metadata feature.- Parameters:
feature- metadata feature- Returns:
- metaclass name, or null
-
getMetaclassName
Returns the name of the given metaclass.- Parameters:
metaclass- metaclass- Returns:
- short name or name, or null
-
isApplicable
Checks whether metadata is applicable to the given element.- Parameters:
element- element- Returns:
- true if metadata can be applied
-
getSelfMetadata
Returns the self metadata feature of the element, if any.- Parameters:
element- element- Returns:
- self metadata, or null
-
isSelfMetadata
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
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- projecteClass- EClass- Returns:
- metaclass, or null
-
getEClassFor
Returns the EClass corresponding to the given metaclass.- Parameters:
metaclass- metaclass- Returns:
- EClass, or null
-
isMetamodelFeature
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
Checks whether the element is annotated with owned metadata of the given metaclass.- Parameters:
element- elementmetaclass- 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- elementmetaclasses- metaclasses- Returns:
- true if the element matches any metaclass
-
isInstanceOfMetamodelMetaclass
Checks whether the element is an instance of the given metamodel metaclass.- Parameters:
element- elementmetaclass- metaclass- Returns:
- true if the element matches the metaclass
-