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 -
Constructor Summary
ConstructorsConstructorDescriptionAbstractVariable(String name, IDatatype type, IModelElement parent) Constructor for decision variable declaration.AbstractVariable(String name, IDatatype type, Value defaultValue, IModelElement parent) Constructor for explicit variable creation. -
Method Summary
Modifier and TypeMethodDescriptionvoidCauses theDecisionVariableDeclarationto generate new internal constraints based on the new constraints stored inside theDerivedDatatype.booleanGetter for the value.getType()Returns the type of this variable.inthashCode()abstract booleanReturns whether this variable is an attribute.abstract booleanReturns whether this variable is a constant.booleanisSame(AbstractVariable var) Returns whether two variables are considered as being the same (same name/type).abstract booleanReturns whether this decision variable declaration is used as a temporary variable (in constraints, i.e.voidDefines (possible multiple) default value(s).voidDefines 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, setParentMethods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getUniqueName, isTransparent, propagateAttribute, setComment, setName, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.ssehub.easy.varModel.model.IAttributeAccess
getAttribute, getAttribute, getAttributesCount, getParentMethods inherited from interface net.ssehub.easy.varModel.model.IModelElement
accept
-
Field Details
-
type
-
defaultValue
-
-
Constructor Details
-
AbstractVariable
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
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 Details
-
setValue
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
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
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
Getter for the value.- Returns:
- the value
-
getType
Returns the type of this variable.- Returns:
- the type of this variable
-
isSame
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
-
hashCode
public int hashCode() -
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 theDecisionVariableDeclarationto 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
-