Class TokenEvaluator<T>
- java.lang.Object
-
- com.opengamma.strata.report.framework.expression.TokenEvaluator<T>
-
- Type Parameters:
T- the type of the target
- Direct Known Subclasses:
BeanTokenEvaluator,CurrencyAmountTokenEvaluator,CurrencyParameterSensitivitiesTokenEvaluator,CurrencyParameterSensitivityTokenEvaluator,IterableTokenEvaluator,MapTokenEvaluator,PositionTokenEvaluator,SecurityTokenEvaluator,TradeTokenEvaluator
public abstract class TokenEvaluator<T> extends Object
Evaluates a token against an object to produce another object.Tokens are taken from expressions in a report template. These expressions tell the reporting framework how to navigate a tree of data to find values to include in the report.
For example, if the token is '
index' and the object is aFrathe methodFra.getIndex()will be invoked and the result will contain anIborIndex.
-
-
Constructor Summary
Constructors Constructor Description TokenEvaluator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected EvaluationResultambiguousTokenFailure(T object, String token)Generates a failure result for an ambiguous token.abstract EvaluationResultevaluate(T target, CalculationFunctions functions, String firstToken, List<String> remainingTokens)Evaluates a token against a given object.abstract Class<?>getTargetType()Gets the type against which tokens can be evaluated in this implementation.protected EvaluationResultinvalidTokenFailure(T object, String token)Generates a failure result for an invalid token.abstract Set<String>tokens(T object)Gets the set of supported token for the given object.
-
-
-
Method Detail
-
getTargetType
public abstract Class<?> getTargetType()
Gets the type against which tokens can be evaluated in this implementation.- Returns:
- the evaluation type
-
tokens
public abstract Set<String> tokens(T object)
Gets the set of supported token for the given object.- Parameters:
object- the object against which tokens may be evaluated- Returns:
- the set of supported tokens
-
evaluate
public abstract EvaluationResult evaluate(T target, CalculationFunctions functions, String firstToken, List<String> remainingTokens)
Evaluates a token against a given object.- Parameters:
target- the object against which to evaluate the tokenfunctions- the calculation functionsfirstToken- the first token of the expressionremainingTokens- the remaining tokens in the expression, possibly empty- Returns:
- the result of the evaluation
-
invalidTokenFailure
protected EvaluationResult invalidTokenFailure(T object, String token)
Generates a failure result for an invalid token.- Parameters:
object- the object against which the failure occurredtoken- the invalid token- Returns:
- the failure result
-
ambiguousTokenFailure
protected EvaluationResult ambiguousTokenFailure(T object, String token)
Generates a failure result for an ambiguous token.- Parameters:
object- the object against which the failure occurred.token- the ambiguous token- Returns:
- the failure result
-
-