Package net.ssehub.easy.varModel.model
Class AbstractVariable
- java.lang.Object
-
- net.ssehub.easy.varModel.model.ModelElement
-
- net.ssehub.easy.varModel.model.ContainableModelElement
-
- net.ssehub.easy.varModel.model.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 Summary
Fields Modifier and Type Field Description private ConstraintSyntaxTreedefaultValueprivate IDatatypetype
-
Constructor Summary
Constructors Constructor Description AbstractVariable(java.lang.String name, IDatatype type, IModelElement parent)Constructor for decision variable declaration.AbstractVariable(java.lang.String name, IDatatype type, Value defaultValue, IModelElement parent)Constructor for explicit variable creation.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidconstraintsChanged()Causes the DecisionVariableDeclaration to generate new internal constraints based on the new constraints stored inside theDerivedDatatype.booleanequals(java.lang.Object obj)ConstraintSyntaxTreegetDefaultValue()Getter for the value.IDatatypegetType()Returns the type of this variable.inthashCode()abstract booleanisAttribute()Returns whether this variable is an attribute.abstract booleanisConstant()Returns whether this variable is a constant.booleanisSame(AbstractVariable var)Returns whether two variables are considered as being the same (same name/type).abstract booleanisTemporaryVariable()Returns whether this decision variable declaration is used as a temporary variable (in constraints, i.e.voidsetValue(java.lang.Object... values)Defines (possible multiple) default value(s).voidsetValue(java.lang.String value)Defines the default value.voidsetValue(ConstraintSyntaxTree value)Defines the default value.-
Methods inherited from class net.ssehub.easy.varModel.model.ContainableModelElement
accept, getNameSpace, getParent, getProject, getQualifiedName, getTopLevelParent, isTopLevel, setParent
-
Methods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getUniqueName, isTransparent, propagateAttribute, setComment, setName, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.varModel.model.IAttributeAccess
getAttribute, getAttribute, getAttributesCount, getParent
-
Methods inherited from interface net.ssehub.easy.varModel.model.IModelElement
accept
-
-
-
-
Field Detail
-
type
private IDatatype type
-
defaultValue
private ConstraintSyntaxTree defaultValue
-
-
Constructor Detail
-
AbstractVariable
public AbstractVariable(java.lang.String name, IDatatype type, IModelElement parent)Constructor for decision variable declaration.- Parameters:
name- Name of the decision variable declarationtype- type of the new VariableDeclarationparent- the object, in which this specific one is embedded
-
AbstractVariable
public AbstractVariable(java.lang.String name, IDatatype type, Value defaultValue, IModelElement parent)Constructor for explicit variable creation.- Parameters:
name- Name of the decision variable declarationtype- type of the new VariableDeclarationdefaultValue- the default value (may be null)parent- the object, in which this specific one is embedded
-
-
Method Detail
-
setValue
public void setValue(java.lang.String value) throws ValueDoesNotMatchTypeExceptionDefines 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
public void setValue(ConstraintSyntaxTree value) throws ValueDoesNotMatchTypeException, CSTSemanticException
Defines the default value.- Parameters:
value- the default value.- Throws:
ValueDoesNotMatchTypeException- if one of the default values do not comply to the respective typesCSTSemanticException- in case of type resolution errors
-
setValue
public void setValue(java.lang.Object... values) throws ValueDoesNotMatchTypeExceptionDefines (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:
trueif they are equal,falseelse
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.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:
trueif it is a temporary variable,falseif it is a defined variable in the model
-
constraintsChanged
public void constraintsChanged()
Description copied from interface:IDerivedDatatypeListenerCauses the DecisionVariableDeclaration to generate new internal constraints based on the new constraints stored inside theDerivedDatatype.- Specified by:
constraintsChangedin interfaceIDerivedDatatypeListener
-
isAttribute
public abstract boolean isAttribute()
Returns whether this variable is an attribute.- Returns:
trueif it is an attribute,falseelse
-
isConstant
public abstract boolean isConstant()
Returns whether this variable is a constant.- Returns:
truefor constant,falseelse
-
-