Class Annotations

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

@OpenApiAll public class Annotations extends Object
Utility class to work with Annotation and AnnotatingElement
  • Constructor Details

    • Annotations

      public Annotations()
  • Method Details

    • isAnnotatingElement

      public static boolean isAnnotatingElement(org.eclipse.emf.ecore.EClass eClass)
      Checks whether the given EClass represents an AnnotatingElement.
      Parameters:
      eClass - the class to check
      Returns:
      true if the class is an annotating element
    • annotate

      public static Annotation annotate(Element annotatedElement, AnnotatingElement annotatingElement)
      Creates a new Annotation linking the annotating element to the annotated element. The annotation is added as an owned relationship of the annotating element.
      Parameters:
      annotatedElement - the element being annotated
      annotatingElement - 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 an Annotation to 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 annotated
      annotatingElement - 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 annotated
      filter - class filter for annotating elements
      includeOwned - whether to include owned annotating elements
      includeExternallyDefined - 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