Class InstanceSpecifications

java.lang.Object
com.nomagic.magicdraw.uml2.InstanceSpecifications

public class InstanceSpecifications extends Object
Convenience static methods that operate on or return InstanceSpecification elements.
  • 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 - instance
      property - 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 - instanceSpecification
      definingFeature - 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 specification
      property - feature
      createSlotIfNotExists - create a new slot if needed
      createDefaultValue - 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 for
      classifier - classifier of the instance
      createAll - true, to create slots for all properties (even without default value)
    • createSlotsForDefaultValues

      public static void createSlotsForDefaultValues(InstanceSpecification instance, boolean createAll)
      Creates slots for properties of all assigned classifiers to instance.
      Parameters:
      instance - instance
      createAll - 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 type
      instance - instance to check for compatible classifiers
      checkInherited - 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 - instance
      supplier - 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

      @CheckForNull public static Object getValueBySlot(@CheckForNull Slot slot)
      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 for
      classifiers - classifiers
      createSlots - true if slots with default values needs to be created
      See Also: