Package com.nomagic.uml2.ext.jmi.helpers
Class InstanceSpecificationHelper
java.lang.Object
com.nomagic.uml2.ext.jmi.helpers.CoreHelper
com.nomagic.uml2.ext.jmi.helpers.ValueSpecificationHelper
com.nomagic.uml2.ext.jmi.helpers.ClassifierHelper
com.nomagic.uml2.ext.jmi.helpers.InstanceSpecificationHelper
- Direct Known Subclasses:
ModelHelper
An utility class with utility methods operating on InstanceSpecification domain elements
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<InstanceSpecification>
collectAllInstances
(Classifier classifier, Collection<InstanceSpecification> result) Collect all instances of given classifier.static Slot
createSlot
(InstanceSpecification instance, Property property, boolean createDefaultValue) Creates slot for propertystatic void
createSlotsForDefaultValues
(InstanceSpecification instance, boolean createAll) Creates slots for properties of all assigned classifiers to instance.static void
createSlotsForDefaultValues
(InstanceSpecification instance, Classifier classifier, boolean createAll) Creates slots for properties of given classifier.static Slot
findSlot
(InstanceSpecification instanceSpecification, Property property) Looks for existing slot for a given property in given instance.static List<Association>
getAssignableAssociationsForLink
(InstanceSpecification clientInstance, InstanceSpecification supplierInstance) Gets available associations which are allowed to assign for a link.static Collection<Association>
getAssociationOfLink
(InstanceSpecification instance) Gets Association classifier from Link InstanceSpecification, if exists.static Collection<InstanceSpecification>
getLinksBetweenInstances
(InstanceSpecification client, InstanceSpecification supplier) Returns links found between client and supplier instancesstatic Slot
getNestedSlot
(InstanceSpecification instanceSpecification, Property property, List<Property> path, int index) static Slot
getSlot
(InstanceSpecification instance, Property property, boolean createSlotIfNotExists) Returns existing of creates a new Slot for the given property.static Slot
getSlot
(InstanceSpecification instance, Property property, boolean createSlotIfNotExists, boolean createDefaultValue) Returns existing of creates a new Slot for the given propertystatic Object
getValueBySlot
(Slot slot) Retrieves values of slots as object, not as ValueSpecifications.static boolean
isInstanceSpecificationCompatibleWithType
(Classifier type, InstanceSpecification instance) Checks if given instance specification is compatible with given Type.static boolean
isInstanceSpecificationCompatibleWithType
(Classifier type, InstanceSpecification instance, boolean checkInherited) Checks if given instance specification is compatible with given Type.static boolean
isLink
(InstanceSpecification instance) Checks if InstanceSpecification is Link.static void
setClassifierForInstanceSpecification
(Classifier classifier, InstanceSpecification instance, boolean createSlots) Set classifier for instancestatic void
setClassifierForInstanceSpecification
(Collection<? extends Classifier> classifiers, InstanceSpecification instance, boolean createSlots) Set classifiers for instancestatic void
setSlotValue
(Slot slot, String value) Set slot value from a given string.Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.ClassifierHelper
areEqualParameterTypes, areEqualParameterTypes, associations, associationsIncludingInherited, attributes, checkForDerivedClassifier, collectBaseClassInheritableAttributes, collectCommonAssociations, collectDerivedClassifiersRecursively, collectGeneralClassifiersAndRealizedInterfacesRecursively, collectGeneralClassifiersRecursively, collectInheritedAttributes, collectInheritedBehaviors, collectInheritedEnumerationLiterals, collectInheritedExtensionPoints, collectInheritedOperations, collectInheritedPorts, collectInheritedPureAttributes, collectInheritedPureAttributes, collectInheritedRealizedInterfaces, collectInheritedReceptions, collectInheritedRelations, collectRealizedInterfaces, findAssociationEndForType, findGeneralization, findInterfaceRealization, getAllLiterals, getAssociationEndOwnedByAssociation, getClassifiersIncludingDerived, getClassifiersIncludingDerivedRecursively, getClassifiersIncludingGeneralRecursively, getClassifiersIncludingGeneralRecursively, getDerivedClassifiers, getDerivedClassifiersRecursively, getGeneralClassifiers, getGeneralClassifiersRecursively, getImplementedClasses, getInheritanceDeep, getParameters, getPropertiesWithoutRedefined, getProvided, getRealizedInterfaces, getReturnParameter, getReturnParameter, getReturnParameter, getReturnParameters, isBehavioralFeatureEqual, isClassifierOfType, isClassifierOfType, isDerivedClassifier, isDerivedOrRealizes, isLegalInheritance, isLegalInheritance, isOperationEqual, isReturnParameter, isSameOrDerivedClassifier, isSameOrRedefined, isSecondTypeCompatibleToFirst, isSecondTypeCompatibleToFirst, operations, ports, pureAttributes, receptions, removeDerivedClassifiers, removeRedefined
Methods inherited from class com.nomagic.uml2.ext.jmi.helpers.ValueSpecificationHelper
cloneValueSpecification, createValueSpecification, createValueSpecification, createValueSpecification, createValueSpecification, createValueSpecification, getValueSpecificationClass, getValueSpecificationClass, getValueSpecificationValue, getValueString, isValueSpecificationClassElementValue, setValueDisposeIfNeeded, setValueSpecificationValue, setValueSpecificationValue, setValueSpecificationValue
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
-
Constructor Details
-
InstanceSpecificationHelper
public InstanceSpecificationHelper()
-
-
Method Details
-
findSlot
@CheckForNull public static Slot findSlot(InstanceSpecification instanceSpecification, Property property) Looks for existing slot for a given property in given instance.- Parameters:
instanceSpecification
- instanceproperty
- definingFeature of slot- Returns:
- found slot or null
-
getSlot
@CheckForNull public static Slot getSlot(InstanceSpecification instance, Property property, boolean createSlotIfNotExists) Returns existing of creates a new Slot for the given property. If new Slot is created, it will be filled with value from the property default values.- Parameters:
instance
- instance specificationproperty
- featurecreateSlotIfNotExists
- create a new slot if needed- Returns:
- slot
-
getSlot
@CheckForNull public static Slot getSlot(InstanceSpecification instance, Property property, boolean createSlotIfNotExists, boolean createDefaultValue) Returns existing of creates a new Slot for the given property- Parameters:
instance
- instance specificationproperty
- featurecreateSlotIfNotExists
- create a new slot if neededcreateDefaultValue
- fill slot value from property default value- Returns:
- slot
-
createSlotsForDefaultValues
Creates slots for properties of all assigned classifiers to instance.- Parameters:
instance
- instancecreateAll
- true, to create slots for all properties(even without default value)
-
createSlotsForDefaultValues
public static void createSlotsForDefaultValues(InstanceSpecification instance, Classifier classifier, boolean createAll) Creates slots for properties of given classifier.- Parameters:
instance
- instanceclassifier
- classifiercreateAll
- true, to create slots for all properties (even without default value)
-
createSlot
@CheckForNull public static Slot createSlot(InstanceSpecification instance, Property property, boolean createDefaultValue) Creates slot for property- Parameters:
instance
- instanceproperty
- propertycreateDefaultValue
- fill slot value from property default value- Returns:
- slot for property
-
setSlotValue
Set slot value from a given string. Given string will by parsed by the slot type. For example if slot values are booleans, string should be "true".- Parameters:
slot
- slotvalue
- value string representation.
-
getValueBySlot
Retrieves values of slots as object, not as ValueSpecifications. Takes into account multiplicity of slot's defining feature. Collection is returned if slot multiplicity is many.- Parameters:
slot
- slot- Returns:
- value of slot
-
setClassifierForInstanceSpecification
public static void setClassifierForInstanceSpecification(Classifier classifier, InstanceSpecification instance, boolean createSlots) Set classifier for instance- Parameters:
classifier
- classifierinstance
- instancecreateSlots
- true if slots needs to be created
-
setClassifierForInstanceSpecification
public static void setClassifierForInstanceSpecification(@CheckForNull Collection<? extends Classifier> classifiers, InstanceSpecification instance, boolean createSlots) Set classifiers for instance- Parameters:
classifiers
- classifiersinstance
- instancecreateSlots
- true if slots needs to be created- See Also:
-
getAssignableAssociationsForLink
public static List<Association> getAssignableAssociationsForLink(InstanceSpecification clientInstance, InstanceSpecification supplierInstance) Gets available associations which are allowed to assign for a link.- Parameters:
clientInstance
- client instance specificationsupplierInstance
- supplier instance specification- Returns:
- a list of assignable associations for a link
-
isLink
Checks if InstanceSpecification is Link.- Parameters:
instance
- instance to check- Returns:
- true if it is Link element - it has Association as classifier or has a Link symbol in diagram
-
collectAllInstances
public static Collection<InstanceSpecification> collectAllInstances(Classifier classifier, Collection<InstanceSpecification> result) Collect all instances of given classifier. Instances of derived classifiers are also collected.- Parameters:
classifier
- classifierresult
- result collection- Returns:
- result collection
-
isInstanceSpecificationCompatibleWithType
public static boolean isInstanceSpecificationCompatibleWithType(Classifier type, InstanceSpecification instance) Checks if given instance specification is compatible with given Type. Instance is compatible if its classifiers are compatible with given type.- Parameters:
type
- instance compatibility will be checked against this typeinstance
- instance to check- Returns:
- true if instance is compatible with given type
-
isInstanceSpecificationCompatibleWithType
public static boolean isInstanceSpecificationCompatibleWithType(Classifier type, InstanceSpecification instance, boolean checkInherited) Checks if given instance specification is compatible with given Type. Instance is compatible if its classifiers are compatible with given type.- Parameters:
type
- instance compatibility will be checked against this typeinstance
- instance to checkcheckInherited
- if set to true, parent type will be treated as compatible.- Returns:
- true if instance is compatible with given type
-
getAssociationOfLink
Gets Association classifier from Link InstanceSpecification, if exists.- Parameters:
instance
- Link instance- Returns:
- Associations or empty collection
-
getLinksBetweenInstances
public static Collection<InstanceSpecification> getLinksBetweenInstances(InstanceSpecification client, InstanceSpecification supplier) Returns links found between client and supplier instances- Parameters:
client
- instancesupplier
- instance- Returns:
- links
-
getNestedSlot
@CheckForNull public static Slot getNestedSlot(InstanceSpecification instanceSpecification, Property property, List<Property> path, int index)
-