Package com.nomagic.magicdraw.uml2
Class InstanceSpecifications
java.lang.Object
com.nomagic.magicdraw.uml2.InstanceSpecifications
Convenience static methods that operate on or return InstanceSpecification elements.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<InstanceSpecification>collectInstancesOf(Classifier classifier, Collection<InstanceSpecification> instances) Collect all instances of given classifier.static voidcreateSlotsForDefaultValues(InstanceSpecification instance, boolean createAll) Creates slots for properties of all assigned classifiers to instance.static voidcreateSlotsForDefaultValues(InstanceSpecification instance, Classifier classifier, boolean createAll) Creates slots for properties of given classifier.static Collection<InstanceSpecification>getLinksBetweenInstances(InstanceSpecification client, InstanceSpecification supplier) Returns links found between client and supplier instancesstatic SlotgetNestedSlot(InstanceSpecification instanceSpecification, Property property, List<Property> path, int index) static SlotgetSlot(InstanceSpecification instanceSpecification, Property property) Returns existing slot for a given property in given instance, if anystatic SlotgetSlot(InstanceSpecification instance, Property property, boolean createSlotIfNotExists, boolean createDefaultValue) Returns existing of creates a new Slot for the given propertystatic ObjectgetValueBySlot(Slot slot) Retrieves values of slots as object, not as ValueSpecifications.static booleanisDefiningFeatureSuitable(InstanceSpecification instanceSpecification, Property definingFeature) Method to check if instance owns definingFeature (property) directly or indirectlystatic booleanisInstanceSpecificationCompatibleWithType(Classifier type, InstanceSpecification instance, boolean checkInherited) Checks if given instance specification is compatible with given Type.static voidsetClassifiers(InstanceSpecification instance, Collection<? extends Classifier> classifiers, boolean createSlots) Set classifiers for instance.
-
Constructor Details
-
InstanceSpecifications
public InstanceSpecifications()
-
-
Method Details
-
getSlot
@CheckForNull public static Slot getSlot(InstanceSpecification instanceSpecification, Property property) Returns existing slot for a given property in given instance, if any- Parameters:
instanceSpecification- instanceproperty- definingFeature of slot- Returns:
- slot or null
-
isDefiningFeatureSuitable
public static boolean isDefiningFeatureSuitable(InstanceSpecification instanceSpecification, Property definingFeature) Method to check if instance owns definingFeature (property) directly or indirectly- Parameters:
instanceSpecification- instanceSpecificationdefiningFeature- definingFeature/property- Returns:
- true if instance has property, else false
-
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
-
getNestedSlot
@CheckForNull public static Slot getNestedSlot(InstanceSpecification instanceSpecification, Property property, List<Property> path, int index) -
createSlotsForDefaultValues
public static void createSlotsForDefaultValues(InstanceSpecification instance, Classifier classifier, boolean createAll) Creates slots for properties of given classifier.- Parameters:
instance- instance to create slots forclassifier- classifier of the instancecreateAll- true, to create slots for all properties (even without default value)
-
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)
-
isInstanceSpecificationCompatibleWithType
public static boolean isInstanceSpecificationCompatibleWithType(@CheckForNull 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 check for compatible classifierscheckInherited- if set to true, then classifiers derived/realized from given type will be treated as compatible.- Returns:
- true if instance is compatible with given type
-
getLinksBetweenInstances
public static Collection<InstanceSpecification> getLinksBetweenInstances(InstanceSpecification client, InstanceSpecification supplier) Returns links found between client and supplier instances- Parameters:
client- instancesupplier- instance- Returns:
- links
-
collectInstancesOf
public static Collection<InstanceSpecification> collectInstancesOf(Classifier classifier, Collection<InstanceSpecification> instances) Collect all instances of given classifier. Instances of derived classifiers are also collected.- Parameters:
classifier- classifier- Returns:
- the passed in collection, appended with instances of the classifier and its' subtypes
-
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
-
setClassifiers
public static void setClassifiers(InstanceSpecification instance, @CheckForNull Collection<? extends Classifier> classifiers, boolean createSlots) Set classifiers for instance. Method replaces the classifiers, does not append to the current value- Parameters:
instance- instance to set classifiers forclassifiers- classifierscreateSlots- true if slots with default values needs to be created- See Also:
-