Class Compound

    • Field Detail

      • TYPE

        public static final IDatatype TYPE
        This constant represents the common type of all compounds. Each specific compound type is assignable to this type.
      • TYPE_OF

        public static final Operation TYPE_OF
      • EQUALS

        public static final Operation EQUALS
      • NOTEQUALS

        public static final Operation NOTEQUALS
      • NOTEQUALS_ALIAS

        public static final Operation NOTEQUALS_ALIAS
      • ASSIGNMENT

        public static final Operation ASSIGNMENT
      • IS_DEFINED

        public static final Operation IS_DEFINED
      • isAbstract

        private boolean isAbstract
    • Constructor Detail

      • Compound

        private Compound()
        Creates the singleton instance for TYPE.
      • Compound

        public Compound​(java.lang.String name,
                        ModelElement parent)
        Constructor for a non-abstract compound.
        Parameters:
        name - name of the compound
        parent - the object, in which this specific one is embedded
      • Compound

        public Compound​(java.lang.String name,
                        ModelElement parent,
                        Compound refines)
        Constructor for a non-abstract (potentially refined) compound. [convenience]
        Parameters:
        name - name of the compound
        parent - the object, in which this specific one is embedded
        refines - the super compound (may be null if there is no refinement).
      • Compound

        public Compound​(java.lang.String name,
                        ModelElement parent,
                        Compound... refines)
        Constructor for a non-abstract (potentially refined) compound.
        Parameters:
        name - name of the compound
        parent - the object, in which this specific one is embedded
        refines - the super compounds (may be null if there is no refinement, no entry must be null).
      • Compound

        public Compound​(java.lang.String name,
                        ModelElement parent,
                        boolean isAbstract,
                        Compound refines)
        Constructor for a (potentially abstract, refined) compound. [convenience]
        Parameters:
        name - name of the compound
        isAbstract - whether this compound is abstract
        parent - the object, in which this specific one is embedded
        refines - the super compound (may be null if there is no refinement)
      • Compound

        public Compound​(java.lang.String name,
                        ModelElement parent,
                        boolean isAbstract,
                        Compound... refines)
        Constructor for a (potentially abstract, refined) compound.
        Parameters:
        name - name of the compound
        isAbstract - whether this compound is abstract
        parent - the object, in which this specific one is embedded
        refines - the super compound(s) (may be null if there is no refinement, no entry must be null)
    • Method Detail

      • setRefines

        public void setRefines​(Compound[] refines)
        Setter for the parent/ super compound of a refinement. This method is for incremental build during parsing a IVML file.
        Parameters:
        refines - The super/parent compounds of this compound (may be null, no entry must be null).
      • getImport

        public ProjectImport getImport​(int index)
        Description copied from interface: IResolutionScope
        Returns the project import specified by index.
        Specified by:
        getImport in interface IResolutionScope
        Parameters:
        index - a 0-based index specifying the import to be returned
        Returns:
        the project import
      • hasInterfaces

        public boolean hasInterfaces()
        Description copied from interface: IResolutionScope
        Returns whether this scope has interfaces.
        Specified by:
        hasInterfaces in interface IResolutionScope
        Returns:
        true if it has interfaces, false else
      • isInterface

        public boolean isInterface()
        Description copied from interface: IResolutionScope
        Returns whether this scope is an interfaces.
        Specified by:
        isInterface in interface IResolutionScope
        Returns:
        true if it is an interface, false else
      • getRefinesCount

        public int getRefinesCount()
        The number of refines.
        Returns:
        the number of refines
      • getRefines

        public Compound getRefines​(int index)
        Returns the compound which is refined by this compound.
        Parameters:
        index - the index of the refined compound to return
        Returns:
        the refined compound
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index>=getRefinesCount()
      • accept

        public void accept​(IModelVisitor visitor)
        Accept method for the visitor.
        Specified by:
        accept in interface IModelElement
        Parameters:
        visitor - The visitor, which should process this model element.
      • isAssignableFrom

        public boolean isAssignableFrom​(IDatatype type)
        Determines if the data type represented by this object is either the same as, or is a supertype of type.
        Specified by:
        isAssignableFrom in interface IDatatype
        Overrides:
        isAssignableFrom in class CustomDatatype
        Parameters:
        type - the type being checked
        Returns:
        true if this type is either the same or a supertype of type, true else
      • containsByNameRefines

        public boolean containsByNameRefines​(java.lang.String name)
        Returns whether name is already contained in this or a refined compound.
        Parameters:
        name - the name of the element
        Returns:
        true for contained, false else
      • isRefinedFrom

        public boolean isRefinedFrom​(Compound cmp,
                                     boolean transitive)
        Whether this compound is directly or indirectly refined from cmp.
        Parameters:
        cmp - the cmp to look for
        transitive - whether refines of refines shall be considered
        Returns:
        true if this compound is directly or indirectly refined from cmp
      • getInheritedElementCount

        public int getInheritedElementCount()
        Same behavior as getElementCount(), but also considers inherited elements if this compound is a refinement of another compound.
        Returns:
        The number of contained elements
      • getInheritedElement

        public DecisionVariableDeclaration getInheritedElement​(int index)
        Same behavior as getElement(int) but also considers inherited elements if this compound is a refinement of another compound.
        Parameters:
        index - a 0-based index specifying the nested element to be returned, inherited elements come first, elements of this compound at the end
        Returns:
        the contained element
        Throws:
        java.lang.IndexOutOfBoundsException - if index<0 || index>=getElementCount()
      • addConstraint

        public void addConstraint​(Constraint constraint,
                                  boolean internal)
        Description copied from interface: IDecisionVariableContainer
        Adds a constraint.
        Specified by:
        addConstraint in interface IDecisionVariableContainer
        Parameters:
        constraint - the constraint to be added
        internal - whether the constraint is internally created while building up the model (ignored)
      • sortContainedElements

        public void sortContainedElements​(java.util.Comparator<ContainableModelElement> comp)
        Description copied from interface: IContainableElementsSorter
        Sorts the contained elements (and creates the related datastructure if needed) according to the specified comparator. Please note the following requirements for applying this method:
        • All Elements which were added before this operation must still be member of this project after executing this operation.
        • Comments related to an element must occur before the element in the final sequence.
        Specified by:
        sortContainedElements in interface IContainableElementsSorter
        Parameters:
        comp - a comparator which fulfills the requirements above
      • getModelElement

        public ContainableModelElement getModelElement​(int index)
        Description copied from interface: IDecisionVariableContainer
        Returns a contained model element specified by index. Please note that this method returns all contained model elements, i.e., decision variables and constraints and is intended to restore the input sequence correctly.
        Specified by:
        getModelElement in interface IDecisionVariableContainer
        Parameters:
        index - a 0-based index specifying the operation to be returned
        Returns:
        the contained element
      • getModelElementCount

        public int getModelElementCount()
        Description copied from interface: IDecisionVariableContainer
        Returns the number of contained elements. Please note that this method refers to all contained model elements, i.e., decision variables and constraints and is intended to restore the input sequence correctly.
        Specified by:
        getModelElementCount in interface IDecisionVariableContainer
        Returns:
        the number of contained elements
      • propagateAttribute

        public boolean propagateAttribute​(Attribute attribute)
        Description copied from interface: IModelElement
        Propagates an attribute application from the parent to this element or contained elements. This may imply the creation of clones of the given attribute.
        Specified by:
        propagateAttribute in interface IModelElement
        Overrides:
        propagateAttribute in class ModelElement
        Parameters:
        attribute - the attribute to be propagated
        Returns:
        true if the operation was successful, false if the element is about being attributed multiple times with the same attribute
      • getRealizingCount

        public int getRealizingCount()
        Description copied from interface: IDecisionVariableContainer
        Returns the number of realizing constraints. Please note that these constraints are derived and not originally specified in the input IVML model.
        Specified by:
        getRealizingCount in interface IDecisionVariableContainer
        Returns:
        the number of constraints
      • getRealizing

        public Constraint getRealizing​(int index)
        Description copied from interface: IDecisionVariableContainer
        Returns the specified realizing constraint. Please note that these constraints are derived and not originally specified in the input IVML model.
        Specified by:
        getRealizing in interface IDecisionVariableContainer
        Parameters:
        index - the index of the constraint to be returned
        Returns:
        the specified constraint
      • isAbstract

        public boolean isAbstract()
        Returns whether this compound is abstract, i.e., whether it can be instantiated.
        Returns:
        true if this compound is abstract, false else
      • containsByName

        public boolean containsByName​(java.lang.String name)
        Description copied from interface: IDecisionVariableContainer
        Returns whether this project contains an element and its name.
        Specified by:
        containsByName in interface IDecisionVariableContainer
        Parameters:
        name - the name to search for
        Returns:
        true if this project contains the specified element, false else
      • getRefinesDistanceTo

        public int getRefinesDistanceTo​(Compound cmp)
        Determines the (absolute) refinement distance from this to cmp considering this or cmp as alternative bases to search the hierarchy for.
        Parameters:
        cmp - the compound to determine the distance to
        Returns:
        the (absolute) refines distance between this and cmp, 0 for the same, -1 for no common refinement hierarchy
      • getRefinesDistanceTo

        private int getRefinesDistanceTo​(Compound cmp,
                                         boolean checkOpposite)
        Determines the (absolute) refinement distance from this to cmp optionally considering this or cmp as alternative bases to search the hierarchy for.
        Parameters:
        cmp - the compound to determine the distance to
        checkOpposite - if also the distance between cmp and this shall be considered as result (top-level non-recursive call)
        Returns:
        the (absolute) refines distance between this and cmp, 0 for the same, -1 for no common refinement hierarchy
      • findRefinesDistanceTo

        private int findRefinesDistanceTo​(int res,
                                          Compound cmp)
        Iterates over getRefines(int) to identify the refines distance from this to cmp using res as initial result. No search is performed if res is not negative, i.e., already a distance was determined.
        Parameters:
        res - the initial result to start with
        cmp - the compound to search the refines hierarchy in a recursive manner
        Returns:
        the refines distance, 0 for the same, -1 for no common refinement hierarchy
      • implementingNonAbstract

        public java.util.Collection<Compound> implementingNonAbstract​(IResolutionScope scope)
        Finds the implementing non-abstract types for this compound, i.e., the ones that may instantiate this compound. Searches within scope and transitive imports.
        Parameters:
        scope - the scope to search for
        Returns:
        the implementing non-abstract compound types considering this
        See Also:
        allImplementing(IResolutionScope)
      • pruneAbstract

        public static java.util.Collection<Compound> pruneAbstract​(java.util.Collection<Compound> compounds)
        Prunes abstract compounds from compounds.
        Parameters:
        compounds - the compounds to consider (may be null, the the result is also null)
        Returns:
        compounds without abstract compounds (modifies compounds)
      • pruneNonAbstract

        public static java.util.Collection<Compound> pruneNonAbstract​(java.util.Collection<Compound> compounds)
        Prunes non-abstract compounds from compounds.
        Parameters:
        compounds - the compounds to consider (may be null, the the result is also null)
        Returns:
        compounds without non-abstract compounds (modifies compounds)
      • prune

        private static java.util.Collection<Compound> prune​(java.util.Collection<Compound> compounds,
                                                            boolean pruneAbstract)
        Prunes from compounds.
        Parameters:
        compounds - the compounds to consider (may be null, the the result is also null)
        pruneAbstract - if true prune abstract compounds, if false prune non-abstract compounds
        Returns:
        compounds without those to be pruned (modifies compounds)
      • closestRefining

        public java.util.Collection<Compound> closestRefining​(java.util.Collection<Compound> compounds)
        Returns the compounds from compounds that have minimum refines distance to this.
        Parameters:
        compounds - the compounds to analyze
        Returns:
        the selected compounds, may be empty
        See Also:
        getRefinesDistanceTo(Compound)