Class CollectionElementVariable
- java.lang.Object
-
- net.ssehub.easy.varModel.model.ModelElement
-
- net.ssehub.easy.varModel.model.ContainableModelElement
-
- net.ssehub.easy.varModel.model.AbstractVariable
-
- net.ssehub.easy.varModel.cstEvaluation.CollectionElementVariable
-
- All Implemented Interfaces:
ICollectionElementVariable,IDatatypeVisitable,IDerivedDatatypeListener,IAttributeAccess,IModelElement
class CollectionElementVariable extends AbstractVariable implements ICollectionElementVariable
A temporary variable representing a value of a container. By design decision, container do not have contained decision variables. Anyway, references to container variables can be defined and are resolved via this temporary variable. For resolving this variable for a specific configuration, this class is equipped with a resolution path for deferred variable resolution.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private AbstractVariablebaseprivate intindexprivate IResolutionPathElementpath
-
Constructor Summary
Constructors Constructor Description CollectionElementVariable(AbstractVariable base, IDatatype type, IResolutionPathElement path, int index)Creates a collection element variable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IModelVisitor visitor)Accept method for the visitor.AttributegetAttribute(int index)Returns a specific attribute.AttributegetAttribute(java.lang.String name)Returns a specific (declared) attribute.intgetAttributesCount()Returns the number of (declared) attributes.AbstractVariablegetBaseVariable()The base variable representing the collection.intgetIndex()The index of the element in the collection, i.e., the nested element.booleanisAttribute()Returns whether this variable is an attribute.booleanisConstant()Returns whether this variable is a constant.booleanisTemporaryVariable()Returns whether this decision variable declaration is used as a temporary variable (in constraints, i.e.IDecisionVariableresolve(IConfiguration config)Resolves the element variable to a decision variable.-
Methods inherited from class net.ssehub.easy.varModel.model.AbstractVariable
constraintsChanged, equals, getDefaultValue, getType, hashCode, isSame, setValue, setValue, setValue
-
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
getParent
-
-
-
-
Field Detail
-
base
private AbstractVariable base
-
index
private int index
-
path
private IResolutionPathElement path
-
-
Constructor Detail
-
CollectionElementVariable
CollectionElementVariable(AbstractVariable base, IDatatype type, IResolutionPathElement path, int index)
Creates a collection element variable.- Parameters:
base- the base the collection variabletype- the contained typepath- the path to resolvebasein a configurationindex- the index withinbase
-
-
Method Detail
-
getAttributesCount
public int getAttributesCount()
Description copied from interface:IAttributeAccessReturns the number of (declared) attributes.- Specified by:
getAttributesCountin interfaceIAttributeAccess- Returns:
- the number of attributes
-
getAttribute
public Attribute getAttribute(java.lang.String name)
Description copied from interface:IAttributeAccessReturns a specific (declared) attribute.- Specified by:
getAttributein interfaceIAttributeAccess- Parameters:
name- the name of the attribute- Returns:
- the attribute (or null if not found)
-
getAttribute
public Attribute getAttribute(int index)
Description copied from interface:IAttributeAccessReturns a specific attribute.- Specified by:
getAttributein interfaceIAttributeAccess- Parameters:
index- the index of the attribute- Returns:
- the attribute
-
accept
public void accept(IModelVisitor visitor)
Description copied from interface:IModelElementAccept method for the visitor.- Specified by:
acceptin interfaceIModelElement- Parameters:
visitor- The visitor, which should process this model element.
-
getIndex
public int getIndex()
Description copied from interface:ICollectionElementVariableThe index of the element in the collection, i.e., the nested element.- Specified by:
getIndexin interfaceICollectionElementVariable- Returns:
- the index
-
getBaseVariable
public AbstractVariable getBaseVariable()
Description copied from interface:ICollectionElementVariableThe base variable representing the collection.- Specified by:
getBaseVariablein interfaceICollectionElementVariable- Returns:
- the collection base variable
-
isTemporaryVariable
public boolean isTemporaryVariable()
Description copied from class:AbstractVariableReturns whether this decision variable declaration is used as a temporary variable (in constraints, i.e. the parent is a constraint).- Specified by:
isTemporaryVariablein classAbstractVariable- Returns:
trueif it is a temporary variable,falseif it is a defined variable in the model
-
isAttribute
public boolean isAttribute()
Description copied from class:AbstractVariableReturns whether this variable is an attribute.- Specified by:
isAttributein classAbstractVariable- Returns:
trueif it is an attribute,falseelse
-
resolve
public IDecisionVariable resolve(IConfiguration config)
Description copied from interface:ICollectionElementVariableResolves the element variable to a decision variable.- Specified by:
resolvein interfaceICollectionElementVariable- Parameters:
config- the configuration to resolve on- Returns:
- the resolved decision variable (may be null if not resolvable)
-
isConstant
public boolean isConstant()
Description copied from class:AbstractVariableReturns whether this variable is a constant.- Specified by:
isConstantin classAbstractVariable- Returns:
truefor constant,falseelse
-
-