Class Annotations
java.lang.Object
com.dassault_systemes.modeler.kerml.model.Annotations
Utility class to work with
Annotation and AnnotatingElement-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Annotationannotate(Element annotatedElement, AnnotatingElement annotatingElement) Creates a newAnnotationlinking the annotating element to the annotated element.static AnnotationannotateAsOwned(Element annotatedElement, AnnotatingElement annotatingElement) Creates or reuses anAnnotationto annotate the given element as an owned annotation of the annotating element.static booleancanAnnotateAsOwned(org.eclipse.emf.ecore.EClass annotatedElementEClass) Checks whether the given element type can be annotated as an owned annotation.static <T extends AnnotatingElement>
List<T> getAnnotatingElement(Element element, Class<T> filter, boolean includeOwned, boolean includeExternallyDefined) Returns all annotating elements of the given element that match the filter.static booleanisAnnotatingElement(org.eclipse.emf.ecore.EClass eClass) Checks whether the given EClass represents anAnnotatingElement.static booleanisApplicableAnnotatedElement(org.eclipse.emf.ecore.EClass eClass) Checks whether the given element type is allowed to be annotated.
-
Constructor Details
-
Annotations
public Annotations()
-
-
Method Details
-
isAnnotatingElement
public static boolean isAnnotatingElement(org.eclipse.emf.ecore.EClass eClass) Checks whether the given EClass represents anAnnotatingElement.- Parameters:
eClass- the class to check- Returns:
- true if the class is an annotating element
-
annotate
Creates a newAnnotationlinking the annotating element to the annotated element. The annotation is added as an owned relationship of the annotating element.- Parameters:
annotatedElement- the element being annotatedannotatingElement- the element providing the annotation- Returns:
- created annotation
-
canAnnotateAsOwned
public static boolean canAnnotateAsOwned(org.eclipse.emf.ecore.EClass annotatedElementEClass) Checks whether the given element type can be annotated as an owned annotation. Owned annotations cannot be applied to metadata features, associations, connectors, or other disallowed element types.- Parameters:
annotatedElementEClass- the class of the element being annotated- Returns:
- true if the element can be annotated as owned
-
annotateAsOwned
public static Annotation annotateAsOwned(Element annotatedElement, AnnotatingElement annotatingElement) Creates or reuses anAnnotationto annotate the given element as an owned annotation of the annotating element. If the annotating element is already owned by an annotation, that annotation is reused.- Parameters:
annotatedElement- the element being annotatedannotatingElement- the annotating element- Returns:
- the annotation used or created
-
getAnnotatingElement
public static <T extends AnnotatingElement> List<T> getAnnotatingElement(Element element, Class<T> filter, boolean includeOwned, boolean includeExternallyDefined) Returns all annotating elements of the given element that match the filter. Results may include:- Owned annotations
- Annotating elements owned as members of a namespace
- Externally defined annotating elements
- Type Parameters:
T- annotating element type- Parameters:
element- the element being annotatedfilter- class filter for annotating elementsincludeOwned- whether to include owned annotating elementsincludeExternallyDefined- whether to include externally defined annotating elements- Returns:
- list of matching annotating elements
-
isApplicableAnnotatedElement
public static boolean isApplicableAnnotatedElement(org.eclipse.emf.ecore.EClass eClass) Checks whether the given element type is allowed to be annotated. Certain element types (e.g., specializations, owning memberships, feature chainings, conjugations, type featuring, and annotations) cannot be annotated.- Parameters:
eClass- the class to check- Returns:
- true if the element type is applicable for annotation
-