Class ConstantExpression<V extends Value>
- java.lang.Object
-
- org.ow2.authzforce.core.pdp.api.expression.ConstantExpression<V>
-
- Type Parameters:
V
- concrete value type
- All Implemented Interfaces:
Expression<V>
- Direct Known Subclasses:
ConstantPrimitiveAttributeValueExpression
,FunctionExpression
public abstract class ConstantExpression<V extends Value> extends Object implements Expression<V>
Expression wrapper for constant values - that do not depend on the evaluation context - to be used as Expressions, e.g. to be used as function argument. This is an alternative toValue
extendingExpression
directly, which would break the Acyclic Dependency principle sinceExpression
already has a reference toValue
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Optional<V>
alwaysPresentValue
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConstantExpression(Datatype<V> datatype, V v)
Creates instance of constant value expression
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
evaluate(EvaluationContext context)
Returns the value itselfDatatype<V>
getReturnType()
Gets the expected return type of the expression if evaluated.Optional<V>
getValue()
Returns the constant underlying value (always present)String
toString()
-
-
-
Constructor Detail
-
ConstantExpression
protected ConstantExpression(Datatype<V> datatype, V v) throws IllegalArgumentException
Creates instance of constant value expression- Parameters:
datatype
- value datatypev
- constant value- Throws:
IllegalArgumentException
- ifdatatype == null || v == null
-
-
Method Detail
-
getReturnType
public final Datatype<V> getReturnType()
Description copied from interface:Expression
Gets the expected return type of the expression if evaluated.- Specified by:
getReturnType
in interfaceExpression<V extends Value>
- Returns:
- expression evaluation's return type
-
evaluate
public final V evaluate(EvaluationContext context)
Returns the value itself- Specified by:
evaluate
in interfaceExpression<V extends Value>
- Parameters:
context
- the representation of the request- Returns:
- the result of evaluation that may be a single value T (e.g. function result, AttributeValue, Condition, Match...) or bag of values (e.g. AttributeDesignator, AttributeSelector)
-
getValue
public final Optional<V> getValue()
Returns the constant underlying value (always present)- Specified by:
getValue
in interfaceExpression<V extends Value>
- Returns:
- the constant value iff the expression has a static/fixed/constant value, else no present value. NB: Null is not considered/possible as a constant value for expressions.
-
-