Class FunctionUtils

  • public final class FunctionUtils
    extends java.lang.Object
    Static utility methods useful when writing calculation functions.
    • Method Detail

      • toScenarioArray

        public static <T><T,​java.util.List<T>,​ScenarioArray<T>> toScenarioArray()
        Returns a collector which can be used at the end of a stream of results to build a ScenarioArray.
        Type Parameters:
        T - the type of the results in the stream
        a collector used to create a CurrencyAmountList from a stream of CurrencyAmount
      • toValuesArray

        public static<java.lang.Double,​java.util.List<java.lang.Double>,​DoubleScenarioArray> toValuesArray()
        Returns a collector that builds a scenario result based on Double.

        This is used at the end of a stream to collect per-scenario instances of Double into a single instance of DoubleScenarioArray, which is designed to be space-efficient.

        Note that DoubleStream does not support collectors, which makes this less efficient than it should be.

        a collector used at the end of a stream of Double to build a DoubleScenarioArray
      • duplicateResult

        public static void duplicateResult​(Measure existingKey,
                                           Measure newKey,
                                           java.util.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.
        existingKey - a key for which the map possibly contains a value
        newKey - the key which is inserted into the map
        mutableMeasureMap - a mutable map of values, keyed by measure