Class LocalConfiguration
- java.lang.Object
-
- net.ssehub.easy.varModel.cstEvaluation.LocalConfiguration
-
- All Implemented Interfaces:
IRestrictionEvaluationContext,IConfiguration
public class LocalConfiguration extends java.lang.Object implements IConfiguration, IRestrictionEvaluationContext
Creates a local configuration instance.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<AbstractVariable,IDecisionVariable>map
-
Constructor Summary
Constructors Constructor Description LocalConfiguration()Creates a local configuration instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IDecisionVariableaddDecision(IDecisionVariable decision)Adds a (local) decision to this configuration.(package private) Valuebind(IDatatype type, EvaluationContext context)Binds the giventypeto the first matching decision variable.voidendEvaluation(java.lang.Object processor)Notifies the context about the end of the evaluation.ValuegetAllInstances(IDatatype type)Returns all instances oftype.IDecisionVariablegetDecision(AbstractVariable declaration)Returns the specifiedIDecisionVariable.(package private) voidrebind(CustomOperation actual, CustomOperation replacement)Rebinds the parameters fromactualtoreplacement, e.g., for dynamic dispatch.voidsetValue(IVariable variable, Version version)Defines the value for the given variable in this context.java.lang.ObjectstartEvaluation()Notifies the context about starting the evaluation.java.lang.StringtoString()voidunsetValue(IVariable variable)Unsets the value for the given variable.
-
-
-
Field Detail
-
map
private java.util.Map<AbstractVariable,IDecisionVariable> map
-
-
Method Detail
-
getDecision
public IDecisionVariable getDecision(AbstractVariable declaration)
Description copied from interface:IConfigurationReturns the specifiedIDecisionVariable.- Specified by:
getDecisionin interfaceIConfiguration- Parameters:
declaration- The declaration for which the configuration entity should be returned.- Returns:
- The
IDecisionVariablefor the given declaration
-
addDecision
public IDecisionVariable addDecision(IDecisionVariable decision)
Adds a (local) decision to this configuration.- Parameters:
decision- the related decision- Returns:
decision(builder pattern style)
-
getAllInstances
public Value getAllInstances(IDatatype type)
Description copied from interface:IConfigurationReturns all instances oftype.- Specified by:
getAllInstancesin interfaceIConfiguration- Parameters:
type- the type to return the instances for- Returns:
- all instances of type in terms of a container value consisting of references (may be null if this is not possible, e.g., in case of Integer)
-
bind
Value bind(IDatatype type, EvaluationContext context)
Binds the giventypeto the first matching decision variable. Rationale: Static (all-quantized) variable access needs to be bound automatically. In that case, there is an implicitly created enclosing quantor (rewritten expression), and only one, i.e., the first one can be bound.- Parameters:
type- the type to bind tocontext- the evaluation context- Returns:
- the bound value (may be null if there is none)
-
setValue
public void setValue(IVariable variable, Version version) throws RestrictionEvaluationException
Description copied from interface:IRestrictionEvaluationContextDefines the value for the given variable in this context. May imply that the given variable is added to the context if adequate.- Specified by:
setValuein interfaceIRestrictionEvaluationContext- Parameters:
variable- the variable to be definedversion- the actual value- Throws:
RestrictionEvaluationException- in case that setting the variable fails, e.g., due to type conflicts
-
unsetValue
public void unsetValue(IVariable variable) throws RestrictionEvaluationException
Description copied from interface:IRestrictionEvaluationContextUnsets the value for the given variable. May imply that the variable is removed from the context if adequate.- Specified by:
unsetValuein interfaceIRestrictionEvaluationContext- Parameters:
variable- the variable to be unset- Throws:
RestrictionEvaluationException- in case that setting the variable fails, e.g., due to type conflicts
-
startEvaluation
public java.lang.Object startEvaluation() throws RestrictionEvaluationExceptionDescription copied from interface:IRestrictionEvaluationContextNotifies the context about starting the evaluation.- Specified by:
startEvaluationin interfaceIRestrictionEvaluationContext- Returns:
- returns the evaluation processor
- Throws:
RestrictionEvaluationException- in case that a sub context cannot be created
-
endEvaluation
public void endEvaluation(java.lang.Object processor) throws RestrictionEvaluationExceptionDescription copied from interface:IRestrictionEvaluationContextNotifies the context about the end of the evaluation.- Specified by:
endEvaluationin interfaceIRestrictionEvaluationContext- Parameters:
processor- the evaluation processor for release- Throws:
RestrictionEvaluationException- in case that a sub context cannot be removed
-
rebind
void rebind(CustomOperation actual, CustomOperation replacement)
Rebinds the parameters fromactualtoreplacement, e.g., for dynamic dispatch. As a prerequisite,actualandreplacementmust have the same number of parameters and compatible parameter types, i.e.,replacementmust have the same or more specific parameter types thenactual.- Parameters:
actual- the operation for which the parameters shall be replacereplacement- the operation replacingactual
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-