Class BeanTokenEvaluator

  • public class BeanTokenEvaluator
    extends TokenEvaluator<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 named amounts containing a list of LegAmount instances. The following expressions are equivalent and both return the first amount in the list. LegInitialNotional is a measure that produces LegAmounts.


    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 Detail

      • BeanTokenEvaluator

        public BeanTokenEvaluator()
    • Method Detail

      • getTargetType

        public java.lang.Class<Bean> getTargetType()
        Description copied from class: TokenEvaluator
        Gets the type against which tokens can be evaluated in this implementation.
        Specified by:
        getTargetType in class TokenEvaluator<Bean>
        the evaluation type
      • tokens

        public java.util.Set<java.lang.String> tokens​(Bean bean)
        Description copied from class: TokenEvaluator
        Gets the set of supported token for the given object.
        Specified by:
        tokens in class TokenEvaluator<Bean>
        bean - the object against which tokens may be evaluated
        the set of supported tokens
      • evaluate

        public EvaluationResult evaluate​(Bean bean,
                                         CalculationFunctions functions,
                                         java.lang.String firstToken,
                                         java.util.List<java.lang.String> remainingTokens)
        Description copied from class: TokenEvaluator
        Evaluates a token against a given object.
        Specified by:
        evaluate in class TokenEvaluator<Bean>
        bean - the object against which to evaluate the token
        functions - the calculation functions
        firstToken - the first token of the expression
        remainingTokens - the remaining tokens in the expression, possibly empty
        the result of the evaluation