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
An utility class to work with ValueSpecifications
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ValueSpecification
cloneValueSpecification
(ValueSpecification valueSpecification, Element newOwner) Clones value specificationstatic ValueSpecification
createValueSpecification
(Project project, Type valueType, Object value, boolean checkNullValue, 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, Object value, 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, Object value, ElementsFactory elementsFactory, 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
(Class<? extends ValueSpecification> valueSpecificationClass, Type valueType, Object value, ElementsFactory factory, 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
(Class<? extends ValueSpecification> valueSpecificationClass, Type valueType, Object value, ElementsFactory factory, 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 Class<? extends ValueSpecification>
getValueSpecificationClass
(Type valueType) Return a meta type of ValueSpecification which should be used to store values of given typestatic Class<? extends ValueSpecification>
getValueSpecificationClass
(Type valueType, Object value) Return a meta type of ValueSpecification which should be used to store values of given type or value.static Object
getValueSpecificationValue
(ValueSpecification valueSpecification) Return value of given ValueSpecificationstatic String
getValueString
(ValueSpecification valueSpecification) Return string representation of given ValueSpecificationstatic boolean
isValueSpecificationClassElementValue
(Type valueType) static void
setValueDisposeIfNeeded
(Supplier<ValueSpecification> oldValueSupplier, Consumer<ValueSpecification> newValueConsumer, ValueSpecification newValue) Set value specification as a new value.static ValueSpecification
setValueSpecificationValue
(Project project, ValueSpecification valueSpecification, Type valueType, Object value) Sets value to value specification, creates value specification if necessary.static ValueSpecification
setValueSpecificationValue
(Project project, ValueSpecification valueSpecification, Type valueType, Object value, boolean checkNullValue) Sets value to value specification, creates value specification if necessary.static void
setValueSpecificationValue
(ValueSpecification valueSpecification, Object value) Set a value of value specificationMethods 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
-
Constructor Details
-
ValueSpecificationHelper
public ValueSpecificationHelper()
-
-
Method Details
-
createValueSpecification
@CheckForNull public static ValueSpecification createValueSpecification(Project project, @CheckForNull Type valueType, @CheckForNull Object value, @CheckForNull 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 Object value, boolean checkNullValue, @CheckForNull 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 Object value, ElementsFactory elementsFactory, @CheckForNull 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 Class<? extends ValueSpecification> valueSpecificationClass, @CheckForNull Type valueType, @CheckForNull Object value, ElementsFactory factory, @CheckForNull 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 Class<? extends ValueSpecification> valueSpecificationClass, @CheckForNull Type valueType, @CheckForNull Object value, ElementsFactory factory, @CheckForNull 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 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 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 Object value) Set a value of value specification- Parameters:
valueSpecification
- value specificationvalue
- value
-
getValueSpecificationClass
public static Class<? extends ValueSpecification> getValueSpecificationClass(@CheckForNull Type valueType, @CheckForNull 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
- Parameters:
valueType
- value type- Returns:
- true if ValueSpecification for given type should be ElementValue
-
getValueSpecificationClass
public static 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 Object getValueSpecificationValue(@CheckForNull ValueSpecification valueSpecification) Return value of given ValueSpecification- Parameters:
valueSpecification
- value specification- Returns:
- value
-
getValueString
Return string representation of given ValueSpecification- Parameters:
valueSpecification
- value specification- Returns:
- string representation of given value specification
-
setValueDisposeIfNeeded
public static void setValueDisposeIfNeeded(Supplier<ValueSpecification> oldValueSupplier, 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
-