Class 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 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.

       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 Detail

      • BeanTokenEvaluator

        public BeanTokenEvaluator()
    • 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 class TokenEvaluator<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 class TokenEvaluator<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 class TokenEvaluator<org.joda.beans.Bean>
        Parameters:
        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
        Returns:
        the result of the evaluation