Class AbstractVariable

All Implemented Interfaces:
IDatatypeVisitable, IDerivedDatatypeListener, IAttributeAccess, IModelElement
Direct Known Subclasses:
Attribute, CollectionElementVariable, DecisionVariableDeclaration

public abstract class AbstractVariable extends ContainableModelElement implements IAttributeAccess, IDerivedDatatypeListener
Defines an abstract variable.
Author:
Marcel Lueder, Holger Eichelberger
  • Field Details

  • Constructor Details

    • AbstractVariable

      public AbstractVariable(String name, IDatatype type, IModelElement parent)
      Constructor for decision variable declaration.
      Parameters:
      name - Name of the decision variable declaration
      type - type of the new VariableDeclaration
      parent - the object, in which this specific one is embedded
    • AbstractVariable

      public AbstractVariable(String name, IDatatype type, Value defaultValue, IModelElement parent)
      Constructor for explicit variable creation.
      Parameters:
      name - Name of the decision variable declaration
      type - type of the new VariableDeclaration
      defaultValue - the default value (may be null)
      parent - the object, in which this specific one is embedded
  • Method Details

    • setValue

      public void setValue(String value) throws ValueDoesNotMatchTypeException
      Defines the default value. Note that this method provides exactly one value, not multiple as required in case of containers or compounds.
      Parameters:
      value - the default value.
      Throws:
      ValueDoesNotMatchTypeException - if one of the default values do not comply to the respective types
    • setValue

      Defines the default value.
      Parameters:
      value - the default value.
      Throws:
      ValueDoesNotMatchTypeException - if one of the default values do not comply to the respective types
      CSTSemanticException - in case of type resolution errors
    • setValue

      public void setValue(Object... values) throws ValueDoesNotMatchTypeException
      Defines (possible multiple) default value(s).
      Parameters:
      values - the (possible) multiple values
      Throws:
      ValueDoesNotMatchTypeException - if one of the default values do not comply to the respective types
    • getDefaultValue

      public ConstraintSyntaxTree getDefaultValue()
      Getter for the value.
      Returns:
      the value
    • getType

      public IDatatype getType()
      Returns the type of this variable.
      Returns:
      the type of this variable
    • isSame

      public boolean isSame(AbstractVariable var)
      Returns whether two variables are considered as being the same (same name/type). Please consider that this method does not check for the scope, e.g., whether they are in the same compound.
      Parameters:
      var - the variable to check for
      Returns:
      true if they are equal, false else
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isTemporaryVariable

      public abstract boolean isTemporaryVariable()
      Returns whether this decision variable declaration is used as a temporary variable (in constraints, i.e. the parent is a constraint).
      Returns:
      true if it is a temporary variable, false if it is a defined variable in the model
    • constraintsChanged

      public void constraintsChanged()
      Description copied from interface: IDerivedDatatypeListener
      Causes the DecisionVariableDeclaration to generate new internal constraints based on the new constraints stored inside the DerivedDatatype .
      Specified by:
      constraintsChanged in interface IDerivedDatatypeListener
    • isAttribute

      public abstract boolean isAttribute()
      Returns whether this variable is an attribute.
      Returns:
      true if it is an attribute, false else
    • isConstant

      public abstract boolean isConstant()
      Returns whether this variable is a constant.
      Returns:
      true for constant, false else