Class IterableTokenEvaluator


  • public class IterableTokenEvaluator
    extends TokenEvaluator<java.lang.Iterable<?>>
    Evaluates a token against an iterable object and returns a value.

    The token can be the index of the item in the iterable (zero based). For example, this expression selects the start date of the first leg of a swap:

       Product.legs.0.startDate
     
    It is also possible to select items based on the value of their properties. For example, SwapLeg has a property payReceive whose value can be PAY or RECEIVE. It is possible to select a leg based on the value of this property:
       Product.legs.pay.startDate     // Pay leg start date
       Product.legs.receive.startDate // Receive leg start date
     
    The comparison between property values and expression values is case-insensitive.

    This works for any property where each item has a unique value. For example, consider a cross-currency swap where one leg has the currency USD and the other has the currency GBP:

       Product.legs.USD.startDate // USD leg start date
       Product.legs.GBP.startDate // GBP leg start date
     
    If both legs have the same currency it would obviously not be possible to use the currency to select a leg.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EvaluationResult evaluate​(java.lang.Iterable<?> iterable, CalculationFunctions functions, java.lang.String firstToken, java.util.List<java.lang.String> remainingTokens)
      Evaluates a token against a given object.
      java.lang.Class<?> getTargetType()
      Gets the type against which tokens can be evaluated in this implementation.
      java.util.Set<java.lang.String> tokens​(java.lang.Iterable<?> iterable)
      Gets the set of supported token for the given object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IterableTokenEvaluator

        public IterableTokenEvaluator()
    • Method Detail

      • getTargetType

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

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

        public EvaluationResult evaluate​(java.lang.Iterable<?> iterable,
                                         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<java.lang.Iterable<?>>
        Parameters:
        iterable - 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