@OpenApiAll
public class CoreHelper
extends java.lang.Object
Constructor and Description |
---|
CoreHelper() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areElementsEditable(java.util.Collection<? extends Element> elements)
Indicates if all elements in a collection are editable.
|
static boolean |
canAddChild(BaseElement parent,
BaseElement child)
Checks if current element can add given element.
|
static boolean |
canAssignName(java.lang.String name,
NamedElement data,
boolean symbol)
Checks if given name can be assigned to the given ModelElement.
|
static boolean |
canAssignName(java.lang.String name,
NamedElement data,
boolean symbol,
boolean showError)
Checks if given name can be assigned to the given Element.
|
static boolean |
canAssignName(java.lang.String name,
NamedElement data,
boolean symbol,
boolean showError,
boolean doNotCheckBehavioralFeature)
Checks if given name can be assigned to the given ModelElement.
|
static boolean |
canMoveChildInto(Element parent,
Element child)
Returns true, if child can be moved to the parent.
|
static boolean |
canMoveChildInto(Element parent,
Element child,
boolean checkPermissions)
Returns true, if child can be moved to the parent.
|
static void |
configureBeforeParsing(Property property,
com.nomagic.magicdraw.uml.symbols.editors.TypedElementParsePreprocessor preprocessor) |
static void |
dispose(java.util.Collection<? extends Element> elements)
Dispose all elements in the given collection.
|
static Element |
findAcceptableParentFor(Element element,
Element owner)
Goes up in the hierarchy of ownership until owner is found for a given element.
|
static Element |
findAcceptableParentFor(Element element,
Element owner,
boolean checkPermissions)
Goes up in the hierarchy of ownership until owner is found for a given element.
|
static <T extends Element> |
findOwnerOfStrictType(Element element,
java.lang.Class<T> ownerType)
Finds owner of an element of a specific class type.
|
static <T extends Element> |
findOwnerOfStrictTypeIncludingItself(Element element,
java.lang.Class<T> ownerType)
Finds owner of an element of a specific class type.
|
static <T extends Element> |
findOwnerOfType(Element element,
java.lang.Class<? extends T> ownerType)
Searches for first direct or indirect owner of the given type among owners of the given element.
|
static <T extends Element> |
findOwnerOfTypeIncludingItself(Element element,
java.lang.Class<? extends T> ownerType)
Searches for first direct or indirect owner of the given type among owners of the given element.
|
static Element |
findParent(Element relationship,
Element clientME,
Element supplierME,
Element diagramParent)
Looks for a possible parent for given relationship.
|
static Element |
findParent(Element relationship,
Element clientME,
Element supplierME,
Element diagramParent,
boolean checkPermissions)
Looks for a possible parent for given relationship.
|
static <T extends Element> |
findParentOfType(Element element,
java.lang.Class<? extends T> parentType)
Deprecated.
|
static java.util.Iterator<Element> |
getAdditionalElementsIterator(Element element)
Returns iterator of additional contained elements defined in DSL specification by additionalContentProperty.
|
static Element |
getClientElement(Element relationship)
Get client of the relationship.
|
static java.lang.String |
getComment(Element element)
Returns documentation of given element.
|
static Comment |
getCommentElement(Element element)
Returns documentation Comment for this Element.
|
static Comment |
getCommentElementOrCreate(Element element)
Returns documentation Comment for this element.
|
static java.util.List<NamedElement> |
getDependentClients(NamedElement element,
java.lang.Class<? extends Dependency> dependencyClass)
Collects elements those are connected with Dependencies as clients with a given element
|
static java.util.List<NamedElement> |
getDependentSuppliers(NamedElement element,
java.lang.Class<? extends Dependency> dependencyClass)
Collects elements those are connected with Dependencies as suppliers with a given element
|
static Property |
getFirstMemberEnd(Association assoc)
Get first property member end of association.
|
static java.lang.String |
getMultiplicity(MultiplicityElement element)
Returns multiplicity string for specified multiplicity element.
|
static java.lang.String |
getName(BaseElement element)
Return a name of given element
|
static Element |
getOppositeEnd(Element relationship,
Element end)
Return opposite relationship end
|
static java.util.List<Element> |
getOwnedElementsIncludingAdditional(Element element,
boolean includePureOwned)
Return owned elements of the given Element including additional owned elements defined in DSL specification by additionalContentProperty.
|
static Property |
getSecondMemberEnd(Association assoc)
Get second property member end of association.
|
static Element |
getSupplierElement(Element relationship)
Get supplier of the relationship.
|
static Element |
getSupplierElement(Element relationship,
boolean takeUserFriendly)
Get supplier of the relationship.
|
static java.util.Collection<Element> |
getSupplierElements(java.util.Collection<? extends Element> relationships)
Collect suppliers of the given relationships
|
static boolean |
hasParentIn(java.util.Collection<? extends BaseElement> possibleParents,
BaseElement possibleChild)
Checks if given object is child of any of the given parent objects.
|
static boolean |
isChildOf(java.util.Collection<? extends Element> owners,
Element element)
Is given element is child of some given owner.
|
static boolean |
isDocumentationComment(Comment comment)
Checks if given comment used for storing element documentation.
|
static boolean |
isMultiplicityMany(int value)
Check if given value is 'many' -it is more than 1 or is unlimited (-1).
|
static boolean |
isParentOf(BaseElement possibleParent,
BaseElement possibleChild)
Checks if given object is child of given parent object.
|
static boolean |
isParentOf(Element possibleParent,
Element possibleChild)
Checks if given object is child of given parent object.
|
static boolean |
isRelationship(Element element)
Check if given element is a relationship.
|
static boolean |
isRelationshipAlwaysInClient(java.lang.Class relationshipClass)
Check if relationship if given class type is always owned by a client element
|
static java.lang.String[] |
parseMultiplicityString(java.lang.String expression)
Parses multiplicity of form 1..* and return array of 2 string [lower, upper] representing bounds
|
static void |
setClientElement(Element relationship,
Element client)
Set client of the relationship.
|
static void |
setComment(Element element,
java.lang.String documentation)
Set comment (documentation) for element.
|
static void |
setCommentElement(Element element,
Comment comment)
Set given Comment as documentation of given Element.
|
static void |
setConstraintText(Constraint constraint,
java.lang.String text,
boolean useName,
boolean useExpression)
Set text for constraint as name or as expression
|
static void |
setConstraintText(Constraint constraint,
java.lang.String text,
boolean useName,
boolean useExpression,
boolean showWarnings)
Set text for constraint as name or as expression
|
static void |
setMultiplicity(int lower,
int upper,
MultiplicityElement element)
Set multiplicity to element
|
static void |
setMultiplicity(java.lang.String expression,
MultiplicityElement element)
Sets multiplicity for specified multiplicity element.
|
static void |
setSupplierElement(Element relationship,
Element supplier)
Set supplier of the relationship.
|
public static boolean hasParentIn(java.util.Collection<? extends BaseElement> possibleParents, BaseElement possibleChild)
possibleChild
- possible childpossibleParents
- possible parentspublic static boolean isParentOf(BaseElement possibleParent, BaseElement possibleChild)
possibleChild
- possible childpossibleParent
- possible parentpublic static boolean isParentOf(Element possibleParent, Element possibleChild)
possibleChild
- possible childpossibleParent
- possible parentpublic static void setComment(Element element, java.lang.String documentation)
element
- element to set documentation.documentation
- documentation text.public static java.lang.String getComment(Element element)
element
- element to get documentation.public static Comment getCommentElementOrCreate(Element element)
element
- element@CheckForNull public static Comment getCommentElement(Element element)
element
- elementpublic static void setCommentElement(Element element, Comment comment)
element
- elementcomment
- commentpublic static boolean isDocumentationComment(Comment comment)
comment
- comment@CheckForNull @Deprecated public static <T extends Element> T findParentOfType(@CheckForNull Element element, java.lang.Class<? extends T> parentType)
@CheckForNull public static <T extends Element> T findOwnerOfTypeIncludingItself(@CheckForNull Element element, java.lang.Class<? extends T> ownerType)
element
- element.ownerType
- the meta class of owner to find. Found owner must be instance of this class.@CheckForNull public static <T extends Element> T findOwnerOfType(@CheckForNull Element element, java.lang.Class<? extends T> ownerType)
element
- element.ownerType
- the meta class of owner to find. Found owner must be instance of this class.@CheckForNull public static <T extends Element> T findOwnerOfStrictTypeIncludingItself(Element element, java.lang.Class<T> ownerType)
element
- element for which owner of a specific type should be foundownerType
- class type of the owner@CheckForNull public static <T extends Element> T findOwnerOfStrictType(Element element, java.lang.Class<T> ownerType)
element
- element for which parent of a specific type should be foundownerType
- class type of the ownerpublic static void dispose(java.util.Collection<? extends Element> elements)
elements
- elements to disposepublic static void setMultiplicity(@CheckForNull java.lang.String expression, MultiplicityElement element)
expression
- values that make sense: "0", "1", "*", "0..*", "1..*", "0..1". If null, multiplicity will become unspecifiedelement
- multiplicity element.public static java.lang.String[] parseMultiplicityString(java.lang.String expression)
expression
- expressionpublic static java.lang.String getMultiplicity(MultiplicityElement element)
element
- multiplicity element.public static java.util.Collection<Element> getSupplierElements(java.util.Collection<? extends Element> relationships)
relationships
- relationshipspublic static Element getSupplierElement(Element relationship)
relationship
- relationship model element.@CheckForNull public static Element getSupplierElement(Element relationship, boolean takeUserFriendly)
relationship
- relationship model element.takeUserFriendly
- take user friendly element in some cases (for example owning classifier instead of template signature)public static void setSupplierElement(Element relationship, Element supplier)
relationship
- relationship model element.supplier
- supplier element that will be set to specified relationship model element.@CheckForNull public static Element getClientElement(Element relationship)
relationship
- relationship model element.public static void setClientElement(Element relationship, Element client)
relationship
- relationship model element.client
- client element that will be set to specified relationship model element.public static boolean isMultiplicityMany(int value)
value
- valuepublic static void setMultiplicity(int lower, int upper, MultiplicityElement element)
lower
- loverupper
- upperelement
- elementpublic static Property getFirstMemberEnd(Association assoc)
assoc
- association model element.public static Property getSecondMemberEnd(Association assoc)
assoc
- association model element.public static boolean areElementsEditable(java.util.Collection<? extends Element> elements)
elements
- a collection of elements to check@CheckForNull public static Element findAcceptableParentFor(Element element, @CheckForNull Element owner, boolean checkPermissions)
element
- elementowner
- candidate for ownercheckPermissions
- check editing permissions@CheckForNull public static Element findAcceptableParentFor(Element element, @CheckForNull Element owner)
element
- elementowner
- candidate for ownerpublic static boolean canMoveChildInto(Element parent, Element child)
public static boolean canMoveChildInto(Element parent, Element child, boolean checkPermissions)
public static boolean canAssignName(java.lang.String name, NamedElement data, boolean symbol, boolean showError)
name
- a new name for Elementdata
- a given Elementsymbol
- true if changing symbol nameshowError
- show error in UI in case of name conflictpublic static boolean canAssignName(java.lang.String name, NamedElement data, boolean symbol)
name
- a new name for ModelElement.data
- a given ModelElement.symbol
- true if changing symbol namepublic static boolean canAssignName(java.lang.String name, NamedElement data, boolean symbol, boolean showError, boolean doNotCheckBehavioralFeature)
name
- a new name for ModelElement.data
- a given ModelElement.symbol
- true if changing symbol nameshowError
- show error in UI in case of name conflictpublic static void configureBeforeParsing(Property property, com.nomagic.magicdraw.uml.symbols.editors.TypedElementParsePreprocessor preprocessor)
public static boolean isRelationship(@CheckForNull Element element)
element
- elementpublic static Element getOppositeEnd(Element relationship, Element end)
relationship
- relationshipend
- end@CheckForNull public static Element findParent(Element relationship, Element clientME, Element supplierME, @CheckForNull Element diagramParent)
relationship
- relation for which possible parent should be found.clientME
- relationship client elementsupplierME
- relationship supplier elementdiagramParent
- can be null if diagram is not important in context@CheckForNull public static Element findParent(Element relationship, Element clientME, Element supplierME, @CheckForNull Element diagramParent, boolean checkPermissions)
relationship
- relation for which possible parent should be found.clientME
- relationship client elementsupplierME
- relationship supplier elementdiagramParent
- can be null if diagram is not important in contextcheckPermissions
- indicates if permissions should be checked.public static boolean isRelationshipAlwaysInClient(java.lang.Class relationshipClass)
relationshipClass
- relationship class typepublic static boolean isChildOf(java.util.Collection<? extends Element> owners, Element element)
owners
- the given owners.element
- the given elementpublic static java.util.List<Element> getOwnedElementsIncludingAdditional(Element element, boolean includePureOwned)
includePureOwned
- include element owned directly in ownedElement UML meta propertypublic static java.util.Iterator<Element> getAdditionalElementsIterator(Element element)
public static java.lang.String getName(BaseElement element)
element
- namepublic static boolean canAddChild(BaseElement parent, BaseElement child)
public static void setConstraintText(Constraint constraint, java.lang.String text, boolean useName, boolean useExpression)
constraint
- constrainttext
- textuseName
- set text as nameuseExpression
- set text as expressionpublic static void setConstraintText(Constraint constraint, java.lang.String text, boolean useName, boolean useExpression, boolean showWarnings)
constraint
- constrainttext
- textuseName
- set text as nameuseExpression
- set text as expressionshowWarnings
- shows parsing warnings in UI if there were anypublic static java.util.List<NamedElement> getDependentClients(NamedElement element, java.lang.Class<? extends Dependency> dependencyClass)
element
- the given elementdependencyClass
- dependency class to filterpublic static java.util.List<NamedElement> getDependentSuppliers(NamedElement element, java.lang.Class<? extends Dependency> dependencyClass)
element
- the given elementdependencyClass
- dependency class to filter