Package com.nomagic.uml2.ext.jmi.helpers
Class ValueSpecificationHelper
- java.lang.Object
-
- com.nomagic.uml2.ext.jmi.helpers.CoreHelper
-
- com.nomagic.uml2.ext.jmi.helpers.ValueSpecificationHelper
-
- Direct Known Subclasses:
ClassifierHelper
@OpenApiAll public class ValueSpecificationHelper extends CoreHelper
An utility class to work with ValueSpecifications
-
-
Constructor Summary
Constructors Constructor Description ValueSpecificationHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ValueSpecification
cloneValueSpecification(ValueSpecification valueSpecification, Element newOwner)
Clones value specificationstatic ValueSpecification
createValueSpecification(Project project, Type valueType, java.lang.Object value, boolean checkNullValue, java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.static ValueSpecification
createValueSpecification(Project project, Type valueType, java.lang.Object value, java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.static ValueSpecification
createValueSpecification(Type valueType, java.lang.Object value, ElementsFactory elementsFactory, java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.static ValueSpecification
createValueSpecification(java.lang.Class<? extends ValueSpecification> valueSpecificationClass, Type valueType, java.lang.Object value, ElementsFactory factory, java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.static ValueSpecification
createValueSpecification(java.lang.Class<? extends ValueSpecification> valueSpecificationClass, Type valueType, java.lang.Object value, ElementsFactory factory, java.util.Collection<? extends ValueSpecification> reuse, boolean ignoreValuesOfReuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.static java.lang.Class<? extends ValueSpecification>
getValueSpecificationClass(Type valueType)
Return a meta type of ValueSpecification which should be used to store values of given typestatic java.lang.Class<? extends ValueSpecification>
getValueSpecificationClass(Type valueType, java.lang.Object value)
Return a meta type of ValueSpecification which should be used to store values of given type or value.static java.lang.Object
getValueSpecificationValue(ValueSpecification valueSpecification)
Return value of given ValueSpecificationstatic java.lang.String
getValueString(ValueSpecification valueSpecification)
Return string representation of given ValueSpecificationstatic boolean
isValueSpecificationClassElementValue(Type valueType)
static void
setValueDisposeIfNeeded(java.util.function.Supplier<ValueSpecification> oldValueSupplier, java.util.function.Consumer<ValueSpecification> newValueConsumer, ValueSpecification newValue)
Set value specification as a new value.static ValueSpecification
setValueSpecificationValue(Project project, ValueSpecification valueSpecification, Type valueType, java.lang.Object value)
Sets value to value specification, creates value specification if necessary.static ValueSpecification
setValueSpecificationValue(Project project, ValueSpecification valueSpecification, Type valueType, java.lang.Object value, boolean checkNullValue)
Sets value to value specification, creates value specification if necessary.static void
setValueSpecificationValue(ValueSpecification valueSpecification, java.lang.Object value)
Set a value of value specification-
Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.CoreHelper
areElementsEditable, canAddChild, canAssignName, canAssignName, canAssignName, canMoveChildInto, canMoveChildInto, collectRelationships, collectRelationships, collectRelationshipsByType, collectRelationshipsIncludeIndirect, dispose, findAcceptableParentFor, findAcceptableParentFor, findOwnerOfStrictType, findOwnerOfStrictTypeIncludingItself, findOwnerOfType, findOwnerOfTypeIncludingItself, findParent, findParent, getAdditionalElementsIterator, getClientElement, getComment, getCommentElement, getCommentElementOrCreate, getDependentClients, getDependentSuppliers, getFirstMemberEnd, getMultiplicity, getName, getOppositeEnd, getOwnedElementsIncludingAdditional, getSecondMemberEnd, getSupplierElement, getSupplierElement, getSupplierElements, hasParentIn, isChildOf, isDocumentationComment, isMultiplicityMany, isParentOf, isParentOf, isRelationship, isRelationshipAlwaysInClient, parseMultiplicityString, setClientElement, setComment, setCommentElement, setConstraintText, setConstraintText, setMultiplicity, setMultiplicity, setSupplierElement
-
-
-
-
Method Detail
-
createValueSpecification
@CheckForNull public static ValueSpecification createValueSpecification(Project project, @CheckForNull Type valueType, @CheckForNull java.lang.Object value, @CheckForNull java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.- Parameters:
project
- projectvalueType
- type defining the value specificationvalue
- value value of ValueSpecificationreuse
- a collection of possible value specifications to reuse- Returns:
- specification
-
createValueSpecification
@CheckForNull public static ValueSpecification createValueSpecification(Project project, @CheckForNull Type valueType, @CheckForNull java.lang.Object value, boolean checkNullValue, @CheckForNull java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.- Parameters:
project
- projectvalueType
- type defining the value specificationvalue
- value value of ValueSpecificationcheckNullValue
- if true and value is null, null is returnedreuse
- a collection of possible value specifications to reuse- Returns:
- specification
-
createValueSpecification
@CheckForNull public static ValueSpecification createValueSpecification(@CheckForNull Type valueType, @CheckForNull java.lang.Object value, ElementsFactory elementsFactory, @CheckForNull java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.- Parameters:
valueType
- type defining the value specificationvalue
- value value of ValueSpecificationelementsFactory
- factoryreuse
- a collection of possible value specifications to reuse- Returns:
- specification
-
createValueSpecification
@CheckForNull public static ValueSpecification createValueSpecification(@CheckForNull java.lang.Class<? extends ValueSpecification> valueSpecificationClass, @CheckForNull Type valueType, @CheckForNull java.lang.Object value, ElementsFactory factory, @CheckForNull java.util.Collection<? extends ValueSpecification> reuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.- Parameters:
valueSpecificationClass
- meta type of value specificationvalue
- value value of ValueSpecificationfactory
- factoryreuse
- a collection of possible value specifications to reuse- Returns:
- specification
-
createValueSpecification
@CheckForNull public static ValueSpecification createValueSpecification(@CheckForNull java.lang.Class<? extends ValueSpecification> valueSpecificationClass, @CheckForNull Type valueType, @CheckForNull java.lang.Object value, ElementsFactory factory, @CheckForNull java.util.Collection<? extends ValueSpecification> reuse, boolean ignoreValuesOfReuse)
Create a new value specification for a given value or returns a suitable from the given specifications to reuse.- Parameters:
valueSpecificationClass
- meta type of value specificationvalue
- value value of ValueSpecificationfactory
- factoryreuse
- a collection of possible value specifications to reuseignoreValuesOfReuse
- if false, checks is value if reuse candidate is suitable, not only the meta type. If true, checks just a metatype and overwrites the value- Returns:
- specification
-
setValueSpecificationValue
@CheckForNull public static ValueSpecification setValueSpecificationValue(Project project, @CheckForNull ValueSpecification valueSpecification, @CheckForNull Type valueType, @CheckForNull java.lang.Object value)
Sets value to value specification, creates value specification if necessary. If valueSpecification is passed, set a value to it. If value is null, passed value specification is disposed and null is returned.- Parameters:
project
- projectvalueSpecification
- value specificationvalueType
- value typevalue
- value- Returns:
- passed value specification or created a new one. If value is null, null can be returned.
-
setValueSpecificationValue
@CheckForNull public static ValueSpecification setValueSpecificationValue(Project project, @CheckForNull ValueSpecification valueSpecification, @CheckForNull Type valueType, @CheckForNull java.lang.Object value, boolean checkNullValue)
Sets value to value specification, creates value specification if necessary. If valueSpecification is passed, set a value to it. If value is null and checkNullValue is true, passed value specification is disposed and null is returned.- Parameters:
project
- projectvalueSpecification
- value specificationvalueType
- value typevalue
- valuecheckNullValue
- check null value- Returns:
- passed value specification or created a new one. If value is null, null can be returned.
-
setValueSpecificationValue
public static void setValueSpecificationValue(ValueSpecification valueSpecification, @CheckForNull java.lang.Object value)
Set a value of value specification- Parameters:
valueSpecification
- value specificationvalue
- value
-
getValueSpecificationClass
public static java.lang.Class<? extends ValueSpecification> getValueSpecificationClass(@CheckForNull Type valueType, @CheckForNull java.lang.Object value)
Return a meta type of ValueSpecification which should be used to store values of given type or value. If valueType is null, value is used to define a meta type of value specification.- Parameters:
valueType
- value type- Returns:
- meta type of value specification
-
isValueSpecificationClassElementValue
public static boolean isValueSpecificationClassElementValue(@CheckForNull Type valueType)
- Parameters:
valueType
- value type- Returns:
- true if ValueSpecification for given type should be ElementValue
-
getValueSpecificationClass
public static java.lang.Class<? extends ValueSpecification> getValueSpecificationClass(@CheckForNull Type valueType)
Return a meta type of ValueSpecification which should be used to store values of given type- Parameters:
valueType
- value type- Returns:
- meta type of value specification
-
cloneValueSpecification
@CheckForNull public static ValueSpecification cloneValueSpecification(ValueSpecification valueSpecification, @CheckForNull Element newOwner)
Clones value specification- Parameters:
valueSpecification
- value specification to clonenewOwner
- owner of new value specification. It will not be set as owner, but it should be passed for correct cloning- Returns:
- cloned value specification
-
getValueSpecificationValue
@CheckForNull public static java.lang.Object getValueSpecificationValue(@CheckForNull ValueSpecification valueSpecification)
Return value of given ValueSpecification- Parameters:
valueSpecification
- value specification- Returns:
- value
-
getValueString
public static java.lang.String getValueString(@CheckForNull ValueSpecification valueSpecification)
Return string representation of given ValueSpecification- Parameters:
valueSpecification
- value specification- Returns:
- string representation of given value specification
-
setValueDisposeIfNeeded
public static void setValueDisposeIfNeeded(java.util.function.Supplier<ValueSpecification> oldValueSupplier, java.util.function.Consumer<ValueSpecification> newValueConsumer, @CheckForNull ValueSpecification newValue)
Set value specification as a new value. If old value is not the same as new value, old ValueSpecification is disposed.- Parameters:
oldValueSupplier
- the supplier of olf valuenewValueConsumer
- the consumer of new valuenewValue
- new value
-
-