Class IterableTokenEvaluator
- java.lang.Object
-
- com.opengamma.strata.report.framework.expression.TokenEvaluator<Iterable<?>>
-
- com.opengamma.strata.report.framework.expression.IterableTokenEvaluator
-
public class IterableTokenEvaluator extends TokenEvaluator<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 propertypayReceive
whose value can bePAY
orRECEIVE
. 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.
-
-
Constructor Summary
Constructors Constructor Description IterableTokenEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EvaluationResult
evaluate(Iterable<?> iterable, CalculationFunctions functions, String firstToken, List<String> remainingTokens)
Evaluates a token against a given object.Class<?>
getTargetType()
Gets the type against which tokens can be evaluated in this implementation.Set<String>
tokens(Iterable<?> iterable)
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<?> getTargetType()
Description copied from class:TokenEvaluator
Gets the type against which tokens can be evaluated in this implementation.- Specified by:
getTargetType
in classTokenEvaluator<Iterable<?>>
- Returns:
- the evaluation type
-
tokens
public Set<String> tokens(Iterable<?> iterable)
Description copied from class:TokenEvaluator
Gets the set of supported token for the given object.- Specified by:
tokens
in classTokenEvaluator<Iterable<?>>
- Parameters:
iterable
- the object against which tokens may be evaluated- Returns:
- the set of supported tokens
-
evaluate
public EvaluationResult evaluate(Iterable<?> iterable, CalculationFunctions functions, String firstToken, List<String> remainingTokens)
Description copied from class:TokenEvaluator
Evaluates a token against a given object.- Specified by:
evaluate
in classTokenEvaluator<Iterable<?>>
- Parameters:
iterable
- 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
-
-