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

@OpenApiAll public class Elements extends Object
Utility class to work with Element
  • Constructor Details

    • Elements

      public Elements()
  • Method Details

    • dispose

      public static void dispose(Collection<? extends Element> elements)
      Disposes the given elements using ElementDisposer, ensuring that disposal is performed on a stable array snapshot.
      Parameters:
      elements - elements to dispose
    • selfDispose

      public static void selfDispose(Collection<? extends Element> elements)
      Calls ModelElement.selfDispose() on each element in the collection.
      Parameters:
      elements - elements to dispose
    • selfDisposeUnsettingOwningRelationship

      public static void selfDisposeUnsettingOwningRelationship(Collection<? extends Element> elements)
      Unsets the owning relationship of each element and then disposes it.
      Parameters:
      elements - elements to dispose
    • selfDisposeOwningRelationship

      public static void selfDisposeOwningRelationship(Element element)
      Disposes the owning relationship of the given element, if present.
      Parameters:
      element - element whose owning relationship should be disposed
    • getContainer

      @CheckForNull public static Element getContainer(Element element)
      Returns the EMF container of the element if it is also a KerML Element.
      Parameters:
      element - element
      Returns:
      container element, or null
    • setOwningMembership

      @CheckForNull public static <M extends OwningMembership> M setOwningMembership(Element member, @CheckForNull Namespace namespace, @CheckForNull org.eclipse.emf.ecore.EClass preferredMembershipEClass)
      Establish preferred OwningMembership between a member and given namespace. Current membership will be used(if valid) and if preferred is unspecified. Ignores preferred membership kind if it is more general than the current one. Default membership kind will be used if current/preferred is invalid or unspecified.
      Parameters:
      member - member
      namespace - namespace
      preferredMembershipEClass - kind of preferred OwningMembership
    • setOwningMembership

      @CheckForNull public static <M extends OwningMembership> M setOwningMembership(Element member, @CheckForNull Namespace namespace, @CheckForNull org.eclipse.emf.ecore.EClass membershipEClass, boolean preferredMembershipClass)
      Establish preferred OwningMembership between a member and given namespace. Current membership will be used(if valid) and if preferred is unspecified. Ignores preferred membership kind if it is more general than the current one. Default membership kind will be used if current/preferred is invalid or unspecified.
      Parameters:
      member - member
      namespace - namespace
      membershipEClass - OwningMembership kind
      preferredMembershipClass - true if membershipEClass should be treated as preferred, false if as exact
    • setOwningElement

      public static void setOwningElement(Element element, @CheckForNull Element owning)
      Sets the owning element of the given element. Depending on the type of the owning element, this may create an annotation, set an owning relationship, or assign a standard owner.
      Parameters:
      element - element to update
      owning - new owning element, or null
    • consumeRecursively

      public static void consumeRecursively(Collection<? extends Element> elements, Consumer<Element> consumer)
      Recursively applies the consumer to each element in the collection.
      Parameters:
      elements - elements to traverse
      consumer - consumer applied to each element
    • consumeRecursively

      public static void consumeRecursively(Element element, Consumer<Element> consumer)
      Recursively applies the consumer to the element and all its owned elements.
      Parameters:
      element - root element
      consumer - consumer applied to each element
    • applyRecursively

      public static void applyRecursively(Element element, Function<Element,Boolean> function)
      Recursively applies the function to the element and its owned elements until the function returns false.
      Parameters:
      element - root element
      function - function returning true to continue recursion
    • findOwner

      @CheckForNull public static Element findOwner(Element element, Predicate<Element> condition)
      Finds the first owner in the containment chain that satisfies the condition.
      Parameters:
      element - starting element
      condition - predicate applied to owners
      Returns:
      matching owner, or null