Class Elements
java.lang.Object
com.dassault_systemes.modeler.kerml.model.Elements
Utility class to work with
Element-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyRecursively(Element element, Function<Element, Boolean> function) Recursively applies the function to the element and its owned elements until the function returns false.static voidconsumeRecursively(Element element, Consumer<Element> consumer) Recursively applies the consumer to the element and all its owned elements.static voidconsumeRecursively(Collection<? extends Element> elements, Consumer<Element> consumer) Recursively applies the consumer to each element in the collection.static voiddispose(Collection<? extends Element> elements) Disposes the given elements usingElementDisposer, ensuring that disposal is performed on a stable array snapshot.static ElementFinds the first owner in the containment chain that satisfies the condition.static ElementgetContainer(Element element) Returns the EMF container of the element if it is also a KerMLElement.static voidselfDispose(Collection<? extends Element> elements) CallsModelElement.selfDispose()on each element in the collection.static voidselfDisposeOwningRelationship(Element element) Disposes the owning relationship of the given element, if present.static voidselfDisposeUnsettingOwningRelationship(Collection<? extends Element> elements) Unsets the owning relationship of each element and then disposes it.static voidsetOwningElement(Element element, Element owning) Sets the owning element of the given element.static <M extends OwningMembership>
MsetOwningMembership(Element member, Namespace namespace, org.eclipse.emf.ecore.EClass preferredMembershipEClass) Establish preferredOwningMembershipbetween a member and given namespace.static <M extends OwningMembership>
MsetOwningMembership(Element member, Namespace namespace, org.eclipse.emf.ecore.EClass membershipEClass, boolean preferredMembershipClass) Establish preferredOwningMembershipbetween a member and given namespace.
-
Constructor Details
-
Elements
public Elements()
-
-
Method Details
-
dispose
Disposes the given elements usingElementDisposer, ensuring that disposal is performed on a stable array snapshot.- Parameters:
elements- elements to dispose
-
selfDispose
CallsModelElement.selfDispose()on each element in the collection.- Parameters:
elements- elements to dispose
-
selfDisposeUnsettingOwningRelationship
Unsets the owning relationship of each element and then disposes it.- Parameters:
elements- elements to dispose
-
selfDisposeOwningRelationship
Disposes the owning relationship of the given element, if present.- Parameters:
element- element whose owning relationship should be disposed
-
getContainer
Returns the EMF container of the element if it is also a KerMLElement.- 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 preferredOwningMembershipbetween 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- membernamespace- namespacepreferredMembershipEClass- 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 preferredOwningMembershipbetween 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- membernamespace- namespacemembershipEClass- OwningMembership kindpreferredMembershipClass- true if membershipEClass should be treated as preferred, false if as exact
-
setOwningElement
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 updateowning- 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 traverseconsumer- consumer applied to each element
-
consumeRecursively
Recursively applies the consumer to the element and all its owned elements.- Parameters:
element- root elementconsumer- consumer applied to each element
-
applyRecursively
Recursively applies the function to the element and its owned elements until the function returns false.- Parameters:
element- root elementfunction- function returning true to continue recursion
-
findOwner
Finds the first owner in the containment chain that satisfies the condition.- Parameters:
element- starting elementcondition- predicate applied to owners- Returns:
- matching owner, or null
-