Package com.opengamma.strata.calc.runner
Class FunctionUtils
- java.lang.Object
-
- com.opengamma.strata.calc.runner.FunctionUtils
-
public final class FunctionUtils extends Object
Static utility methods useful when writing calculation functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidduplicateResult(Measure existingKey, Measure newKey, Map<Measure,Result<?>> mutableMeasureMap)Checks if a map of results contains a value for a key, and if it does inserts it into the map for a different key.static Collector<CurrencyAmount,List<CurrencyAmount>,CurrencyScenarioArray>toCurrencyValuesArray()Returns a collector that builds a single-currency scenerio result.static Collector<MultiCurrencyAmount,List<MultiCurrencyAmount>,MultiCurrencyScenarioArray>toMultiCurrencyValuesArray()Returns a collector that builds a multi-currency scenerio result.static <T> Collector<T,List<T>,ScenarioArray<T>>toScenarioArray()Returns a collector which can be used at the end of a stream of results to build aScenarioArray.static Collector<Double,List<Double>,DoubleScenarioArray>toValuesArray()Returns a collector that builds a scenario result based onDouble.
-
-
-
Method Detail
-
toScenarioArray
public static <T> Collector<T,List<T>,ScenarioArray<T>> toScenarioArray()
Returns a collector which can be used at the end of a stream of results to build aScenarioArray.- Type Parameters:
T- the type of the results in the stream- Returns:
- a collector used to create a
CurrencyAmountListfrom a stream ofCurrencyAmount
-
toMultiCurrencyValuesArray
public static Collector<MultiCurrencyAmount,List<MultiCurrencyAmount>,MultiCurrencyScenarioArray> toMultiCurrencyValuesArray()
Returns a collector that builds a multi-currency scenerio result.This is used at the end of a stream to collect per-scenario instances of
MultiCurrencyAmountinto a single instance ofMultiCurrencyScenarioArray, which is designed to be space-efficient.- Returns:
- a collector used at the end of a stream of
MultiCurrencyAmountto build aMultiCurrencyScenarioArray
-
toCurrencyValuesArray
public static Collector<CurrencyAmount,List<CurrencyAmount>,CurrencyScenarioArray> toCurrencyValuesArray()
Returns a collector that builds a single-currency scenerio result.This is used at the end of a stream to collect per-scenario instances of
CurrencyAmountinto a single instance ofCurrencyScenarioArray, which is designed to be space-efficient.- Returns:
- a collector used at the end of a stream of
CurrencyAmountto build aCurrencyScenarioArray
-
toValuesArray
public static Collector<Double,List<Double>,DoubleScenarioArray> toValuesArray()
Returns a collector that builds a scenario result based onDouble.This is used at the end of a stream to collect per-scenario instances of
Doubleinto a single instance ofDoubleScenarioArray, which is designed to be space-efficient.Note that
DoubleStreamdoes not support collectors, which makes this less efficient than it should be.- Returns:
- a collector used at the end of a stream of
Doubleto build aDoubleScenarioArray
-
duplicateResult
public static void duplicateResult(Measure existingKey, Measure newKey, Map<Measure,Result<?>> mutableMeasureMap)
Checks if a map of results contains a value for a key, and if it does inserts it into the map for a different key.- Parameters:
existingKey- a key for which the map possibly contains a valuenewKey- the key which is inserted into the mapmutableMeasureMap- a mutable map of values, keyed by measure
-
-