Package net.ssehub.easy.varModel.model
Class ExpressionVersionRestriction
- java.lang.Object
-
- net.ssehub.easy.varModel.model.ExpressionVersionRestriction
-
- All Implemented Interfaces:
IVersionRestriction
public class ExpressionVersionRestriction extends java.lang.Object implements IVersionRestriction
A version expression based on IVML constraints.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.basics.modelManagement.IVersionRestriction
IVersionRestriction.IVariableMapper
-
-
Field Summary
Fields Modifier and Type Field Description private DecisionVariableDeclarationcompoundVersionVariableprivate ConstraintSyntaxTreeexprprivate DecisionVariableDeclarationversionVariable
-
Constructor Summary
Constructors Constructor Description ExpressionVersionRestriction(ConstraintSyntaxTree expr, DecisionVariableDeclaration versionVariable, DecisionVariableDeclaration compoundVersionVariable)Creates a new expression version restriction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IVersionRestrictioncopy(IModel model)Copies this version restriction for the givenmodel.IVersionRestrictioncopy(IVersionRestriction.IVariableMapper mapper)Copies this version restriction for the given using the givenmapper.static DecisionVariableDeclaration[]createRestrictionVars(java.lang.String modelName)Creates the restriction variables for IVML models.static ConstraintSyntaxTreecreateSingleRestriction(DecisionVariableDeclaration var, java.lang.String operator, Version version)Creates a typical single restriction from the given variable (seecreateRestrictionVars(String), the operator and the version.voidemit(java.lang.Object context)Emits the version restriction in terms of it's specification representation.booleanevaluate(IRestrictionEvaluationContext context, Version version)Evaluates the restriction.private DecisionVariableDeclarationmap(IVersionRestriction.IVariableMapper mapper, DecisionVariableDeclaration var)Mapsvarviamapper.java.lang.StringtoSpecification()Turns the version restriction into it's specification representation.
-
-
-
Field Detail
-
expr
private ConstraintSyntaxTree expr
-
versionVariable
private DecisionVariableDeclaration versionVariable
-
compoundVersionVariable
private DecisionVariableDeclaration compoundVersionVariable
-
-
Constructor Detail
-
ExpressionVersionRestriction
public ExpressionVersionRestriction(ConstraintSyntaxTree expr, DecisionVariableDeclaration versionVariable, DecisionVariableDeclaration compoundVersionVariable) throws RestrictionEvaluationException
Creates a new expression version restriction.- Parameters:
expr- the version restriction expressionversionVariable- the variable representing the actual version of the project to be importedcompoundVersionVariable- the version variable in terms of the (legacy) compound version- Throws:
RestrictionEvaluationException- in case of type compliance problems
-
-
Method Detail
-
createRestrictionVars
public static DecisionVariableDeclaration[] createRestrictionVars(java.lang.String modelName)
Creates the restriction variables for IVML models.- Parameters:
modelName- the name of the model- Returns:
- the restriction variables (1: the pseudo-compound variable, 0: the plain variable)
-
createSingleRestriction
public static ConstraintSyntaxTree createSingleRestriction(DecisionVariableDeclaration var, java.lang.String operator, Version version) throws ValueDoesNotMatchTypeException, CSTSemanticException
Creates a typical single restriction from the given variable (seecreateRestrictionVars(String), the operator and the version.- Parameters:
var- the variable to useoperator- the operatorversion- the version- Returns:
- the expression
- Throws:
ValueDoesNotMatchTypeException- in case thatversionis invalidCSTSemanticException- in case of constraint composition problems
-
emit
public void emit(java.lang.Object context)
Description copied from interface:IVersionRestrictionEmits the version restriction in terms of it's specification representation.- Specified by:
emitin interfaceIVersionRestriction- Parameters:
context- the output context (interpreted by the respective implementation, e.g., an output visitor in order to continue with the actual indentation, may be null but then nothing is emitted)
-
toSpecification
public java.lang.String toSpecification()
Description copied from interface:IVersionRestrictionTurns the version restriction into it's specification representation.- Specified by:
toSpecificationin interfaceIVersionRestriction- Returns:
- the specification representation
-
evaluate
public boolean evaluate(IRestrictionEvaluationContext context, Version version) throws RestrictionEvaluationException
Description copied from interface:IVersionRestrictionEvaluates the restriction.- Specified by:
evaluatein interfaceIVersionRestriction- Parameters:
context- the output context (interpreted by the respective implementation, e.g., an output visitor in order to continue with the actual indentation, may be null but then false will always be the result)version- the version (of the project) to be used for evaluation- Returns:
trueif the version matches the restriction,falseelse- Throws:
RestrictionEvaluationException- in case of evaluation problems
-
copy
public IVersionRestriction copy(IModel model) throws RestrictionEvaluationException
Description copied from interface:IVersionRestrictionCopies this version restriction for the givenmodel.- Specified by:
copyin interfaceIVersionRestriction- Parameters:
model- the model to copy/instantiate this version restriction for- Returns:
- the copied version restriction (may be null if no restrictions needed to be copied)
- Throws:
RestrictionEvaluationException- in case of evaluation/type problems
-
copy
public IVersionRestriction copy(IVersionRestriction.IVariableMapper mapper) throws RestrictionEvaluationException
Description copied from interface:IVersionRestrictionCopies this version restriction for the given using the givenmapper.- Specified by:
copyin interfaceIVersionRestriction- Parameters:
mapper- the variable mapper- Returns:
- the copied version restriction (may be null if no restrictions needed to be copied)
- Throws:
RestrictionEvaluationException- in case of evaluation/type problems
-
map
private DecisionVariableDeclaration map(IVersionRestriction.IVariableMapper mapper, DecisionVariableDeclaration var)
Mapsvarviamapper.- Parameters:
mapper- the mappervar- the variable to be mapped- Returns:
- the mapped variable, possibly
var
-
-