Class AbstractIvmlVariable

    • Constructor Detail

      • AbstractIvmlVariable

        protected AbstractIvmlVariable​(Configuration cfg,
                                       IDecisionVariable variable,
                                       IVariableFilter filter)
        Creates a new IVML variable.
        Parameters:
        cfg - the parent configuration
        variable - the variable to be wrapped
        filter - the variable filter to apply
    • Method Detail

      • getConfiguration

        public Configuration getConfiguration()
        Returns the configuration.
        Returns:
        the configuration
      • isVariable

        public boolean isVariable​(IDecisionVariable var)
        Returns whether this instances holds var.
        Parameters:
        var - the variable to look for
        Returns:
        true if var is held by this instance, false else
      • getParent

        public IvmlElement getParent()
        Returns the parent of this variable.
        Returns:
        the parent if it exists
      • getVariable

        public IDecisionVariable getVariable()
        Returns the underlying IVML (un-dereferenced) variable.
        Returns:
        the underlying IVML variable
      • getActualType

        public IDatatype getActualType()
        Returns the actual IVML type of decVar.
        Returns:
        the IVML type, if possible the actual, dynamic type, else the declared type
      • getName

        public java.lang.String getName()
        Returns the simple name of the decision variable.
        Specified by:
        getName in interface IResolvable
        Specified by:
        getName in class IvmlElement
        Returns:
        the simple name
      • getQualifiedName

        public java.lang.String getQualifiedName()
        Returns the qualified name of the decision variable.
        Specified by:
        getQualifiedName in class IvmlElement
        Returns:
        the qualified name
      • getVarName

        public java.lang.String getVarName()
        Returns the name of the underlying decision variable. If the variable is referenced (via a reference), then the name of the referenced variable will be returned instead of the variable representing the reference.
        Returns:
        the name of the underlying decision variable
      • getQualifiedVarName

        public java.lang.String getQualifiedVarName()
        Returns the name of the underlying decision variable. If the variable is referenced (via a reference), then the qualified name of the referenced variable will be returned instead of the variable representing the reference.
        Returns:
        the qualified name of the underlying decision variable
      • getType

        public TypeDescriptor<?> getType()
        Returns the type of the (dereferenced) decision variable (VIL view).
        Specified by:
        getType in interface IActualTypeProvider
        Specified by:
        getType in class IvmlElement
        Returns:
        the type (if configured the dynamic, actual type), else the defined type
      • getTypeName

        public java.lang.String getTypeName()
        Returns the simple type name of the (dereferenced) decision variable (VIL view).
        Specified by:
        getTypeName in class IvmlElement
        Returns:
        the simple type name
      • getIvmlType

        public IDatatype getIvmlType()
        Returns the declared IVML type of the (dereferenced) decision variable (VIL view).
        Returns:
        the IVML type
      • getQualifiedType

        public java.lang.String getQualifiedType()
        Returns the qualified type name of the decision variable.
        Specified by:
        getQualifiedType in class IvmlElement
        Returns:
        the qualified type name
      • isConfigured

        public boolean isConfigured()
        Returns whether the underlying decision variable is configured. Please note that this is different from IvmlElement.isNull() as a null value is considered as configured.
        Returns:
        true if the variable is configured, false else
      • isFrozen

        public boolean isFrozen()
        Returns whether this element is frozen.
        Returns:
        true if it is frozen, false else
      • clearValue

        public void clearValue()
        Clears the actual variable. Has no effect if frozen.
      • setValue

        public void setValue​(java.lang.Object value)
        Changes the value of this variable. This method works only if the variable is not frozen, in particular at runtime.
        Parameters:
        value - the new value
      • changeValue

        private void changeValue​(IDecisionVariable toChange,
                                 java.lang.Object value)
        Changes the value of the given variable.
        Parameters:
        toChange - the variable to change
        value - the new value
      • getOriginalValue

        public java.lang.Object getOriginalValue()
        Returns the original value before any change. Intended for runtime reconfiguration. In VIL, this always returns the value of getValue()
        Returns:
        the original value
      • toObject

        public static java.lang.Object toObject​(Value value)
        Returns value into the corresponding (VIL) object value.
        Parameters:
        value - the value
        Returns:
        the object value
      • getValue

        public java.lang.Object getValue()
        Description copied from class: IvmlElement
        Returns the (untyped) value of the decision variable.
        Specified by:
        getValue in class IvmlElement
        Returns:
        the value (may be null)
      • getStringValue

        public java.lang.String getStringValue()
        Description copied from class: IvmlElement
        Returns the string value of the decision variable.
        Specified by:
        getStringValue in class IvmlElement
        Returns:
        the value (may be null)
      • getIntegerValue

        public java.lang.Integer getIntegerValue()
        Description copied from class: IvmlElement
        Returns the integer value of the decision variable.
        Specified by:
        getIntegerValue in class IvmlElement
        Returns:
        the value (may be null)
      • getRealValue

        public java.lang.Double getRealValue()
        Description copied from class: IvmlElement
        Returns the real value of the decision variable.
        Specified by:
        getRealValue in class IvmlElement
        Returns:
        the value (may be null)
      • getBooleanValue

        public java.lang.Boolean getBooleanValue()
        Description copied from class: IvmlElement
        Returns the boolean value of the decision variable.
        Specified by:
        getBooleanValue in class IvmlElement
        Returns:
        the value (may be null)
      • getEnumValue

        public EnumValue getEnumValue()
        Description copied from class: IvmlElement
        Returns the boolean value of the decision variable.
        Specified by:
        getEnumValue in class IvmlElement
        Returns:
        the value (may be null)
      • variables

        public Sequence<DecisionVariable> variables()
        Returns the decision variables contained in this variable. This shall be a sequence to implicitly handle IVML sequences. Primitive values may be obtained using the getter methods. Complex values such as compounds or containers may be accessed via variables().
        Returns:
        the decision variables (unmodifiable)
      • variablesSet

        public Set<DecisionVariable> variablesSet()
        Returns the decision variables contained in this variable as a set.
        Returns:
        the decision variables (unmodifiable)
      • selectAll

        public Configuration selectAll()
        Returns a projected configuration on all nested variables.
        Returns:
        the projected configuration
      • attributes

        public abstract Set<Attribute> attributes()
        Returns the annotations for this variable.
        Returns:
        the decision variables
      • annotations

        public abstract Set<Attribute> annotations()
        Returns the annotations for this variable.
        Returns:
        the decision variables
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • getElement

        public IvmlElement getElement​(java.lang.String name)
        Description copied from class: IvmlElement
        Returns the element matching the given (qualified) name.
        Specified by:
        getElement in class IvmlElement
        Parameters:
        name - the name to search for
        Returns:
        the matching element or null if not found
      • getByName

        public DecisionVariable getByName​(java.lang.String name)
        Returns the decision variable with the given (qualified) name.
        Parameters:
        name - the name of the variable to return
        Returns:
        the variable or null if not found
      • getDecisionVariable

        public IDecisionVariable getDecisionVariable()
        Return the underlying decision variable for internal purpose, such as velocity.
        Returns:
        the decision variable
      • getDeclaration

        public IvmlDeclaration getDeclaration()
        Returns the declaration of this variable in terms of VIL/VTL instances.
        Returns:
        the declaration
      • getInstanceName

        public java.lang.String getInstanceName()
        Description copied from class: IvmlElement
        Returns the instance name of this element.
        Overrides:
        getInstanceName in class IvmlElement
        Returns:
        the instance name
      • createValue

        public void createValue​(boolean override)
        Creates a value matching to this variable and tries to assign it. Failures will be logged and ignored.
        Parameters:
        override - try overriding the existing value (true) or just do nothing if a value already exists (false)
      • createValue

        public void createValue​(TypeDescriptor<?> type,
                                boolean override)
        Creates a value matching to this variable and tries to assign it. Failures will be logged and ignored.
        Parameters:
        type - the type of value to create
        override - try overriding the existing value (true) or just do nothing if a value already exists (false)
      • transferState

        private static void transferState​(IDecisionVariable source,
                                          IDecisionVariable target)
        Transfers the states between source and target. May be required if the configuration initialization just freezes everything without evaluating constraints. The given variables must be of the same type.
        Parameters:
        source - the source variable to take the states from
        target - the target the target variable to apply the states to
      • addValue

        public DecisionVariable addValue()
        Adds a value if the actual variable represents an IVML collection. The declared element type is used as type of the new value.
        Returns:
        the added variable
      • addValue

        public DecisionVariable addValue​(TypeDescriptor<?> type)
        Adds a value if the actual variable represents an IVML collection.
        Parameters:
        type - the desired type of the new variable (must be compatible to the element type of the underlying collection)
        Returns:
        the added variable
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object