Class BeanTokenEvaluator
- java.lang.Object
-
- com.opengamma.strata.report.framework.expression.TokenEvaluator<org.joda.beans.Bean>
-
- com.opengamma.strata.report.framework.expression.BeanTokenEvaluator
-
public class BeanTokenEvaluator extends TokenEvaluator<org.joda.beans.Bean>
Evaluates a token against a bean to produce another object.The token must be the name of one of the properties of the bean and the result is the value of the property.
There is special handling of beans with a single property. The name of the property can be omitted from the expression if the bean only has one property.
For example, the bean
LegAmounts
has a single property namedamounts
containing a list ofLegAmount
instances. The following expressions are equivalent and both return the first amount in the list.LegInitialNotional
is a measure that producesLegAmounts
.Measures.LegInitialNotional.0 Measures.LegInitialNotional.amounts.0
If the token matches the property then the default behaviour applies; the property value is returned and the remaining tokens do not include the property token. If the token doesn't match the property, the property value is returned but the token isn't consumed. i.e. the remaining tokens returned from
evaluate(org.joda.beans.Bean, com.opengamma.strata.calc.runner.CalculationFunctions, java.lang.String, java.util.List<java.lang.String>)
include the first token.
-
-
Constructor Summary
Constructors Constructor Description BeanTokenEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EvaluationResult
evaluate(org.joda.beans.Bean bean, CalculationFunctions functions, String firstToken, List<String> remainingTokens)
Evaluates a token against a given object.Class<org.joda.beans.Bean>
getTargetType()
Gets the type against which tokens can be evaluated in this implementation.Set<String>
tokens(org.joda.beans.Bean bean)
Gets the set of supported token for the given object.-
Methods inherited from class com.opengamma.strata.report.framework.expression.TokenEvaluator
ambiguousTokenFailure, invalidTokenFailure
-
-
-
-
Method Detail
-
getTargetType
public Class<org.joda.beans.Bean> getTargetType()
Description copied from class:TokenEvaluator
Gets the type against which tokens can be evaluated in this implementation.- Specified by:
getTargetType
in classTokenEvaluator<org.joda.beans.Bean>
- Returns:
- the evaluation type
-
tokens
public Set<String> tokens(org.joda.beans.Bean bean)
Description copied from class:TokenEvaluator
Gets the set of supported token for the given object.- Specified by:
tokens
in classTokenEvaluator<org.joda.beans.Bean>
- Parameters:
bean
- the object against which tokens may be evaluated- Returns:
- the set of supported tokens
-
evaluate
public EvaluationResult evaluate(org.joda.beans.Bean bean, CalculationFunctions functions, String firstToken, List<String> remainingTokens)
Description copied from class:TokenEvaluator
Evaluates a token against a given object.- Specified by:
evaluate
in classTokenEvaluator<org.joda.beans.Bean>
- Parameters:
bean
- 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
-
-