Class ExpressionVersionRestriction
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.ExpressionVersionRestriction
-
- All Implemented Interfaces:
IVersionRestriction
- Direct Known Subclasses:
ExpressionVersionRestriction,ExpressionVersionRestriction
public abstract class ExpressionVersionRestriction extends java.lang.Object implements IVersionRestriction
A version restriction based on expressions.- 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 Expressionexprprivate VariableDeclarationversionVariable
-
Constructor Summary
Constructors Constructor Description ExpressionVersionRestriction(Expression expr, VariableDeclaration versionVariable)Creates a new expression version restriction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExpressioncreateSingleRestriction(VariableDeclaration var, java.lang.String operator, Version version)Creates a typical single restriction from the given variable (see#createRestrictionVars(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.protected ExpressiongetExpression()Returns the restriction expression.protected VariableDeclarationgetVersionVariable()Returns the version variable.java.lang.StringtoSpecification()Turns the version restriction into it's specification representation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.basics.modelManagement.IVersionRestriction
copy, copy
-
-
-
-
Field Detail
-
expr
private Expression expr
-
versionVariable
private VariableDeclaration versionVariable
-
-
Constructor Detail
-
ExpressionVersionRestriction
public ExpressionVersionRestriction(Expression expr, VariableDeclaration versionVariable) 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 imported- Throws:
RestrictionEvaluationException- in case of type compliance problems
-
-
Method Detail
-
createSingleRestriction
public static Expression createSingleRestriction(VariableDeclaration var, java.lang.String operator, Version version) throws VilException
Creates a typical single restriction from the given variable (see#createRestrictionVars(String), the operator and the version.- Parameters:
var- the variable to useoperator- the operatorversion- the version- Returns:
- the expression
- Throws:
VilException- in case of type 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
-
getExpression
protected Expression getExpression()
Returns the restriction expression.- Returns:
- the restriction expression
-
getVersionVariable
protected VariableDeclaration getVersionVariable()
Returns the version variable.- Returns:
- the version variable
-
-