Class CalculationResult

  • All Implemented Interfaces:
    java.io.Serializable, Bean, ImmutableBean

    public final class CalculationResult
    extends java.lang.Object
    implements ImmutableBean, java.io.Serializable
    The result of a single calculation.

    This stores the calculated result for a single cell in the output grid. A set of related results for a single target can be stored in a CalculationResults instance.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static CalculationResult of​(int rowIndex,
                                           int columnIndex,
                                           Result<?> result)
        Obtains an instance for the specified row and column index in the output grid.

        The Result object captures the result value, or the failure that prevented the result from being calculated.

        Parameters:
        rowIndex - the row index of the value in the results grid
        columnIndex - the column index of the value in the results grid
        result - the result of the calculation
        Returns:
        a calculation result containing the row index, column index and result object
      • getResult

        public <T> Result<T> getResult​(java.lang.Class<T> type)
        Gets the result of the calculation, casting the result to a known type.

        The result may be a single value or a multi-scenario value. A multi-scenario value will implement ScenarioArray unless it has been aggregated.

        If the calculation did not complete successfully, a failure result will be returned explaining the problem. Callers must check whether the result is a success or failure before examining the result value.

        Type Parameters:
        T - the result type
        Parameters:
        type - the result type
        Returns:
        the result, cast to the specified type
        Throws:
        java.lang.ClassCastException - if the result is not of the specified type
      • withResult

        public CalculationResult withResult​(Result<?> underlyingResult)
        Returns a copy of this result with the underlying result updated.
        Parameters:
        underlyingResult - the new underlying result
        Returns:
        a new instance with the result updated
      • getRowIndex

        public int getRowIndex()
        Gets the row index of the value in the results grid.
        Returns:
        the value of the property
      • getColumnIndex

        public int getColumnIndex()
        Gets the column index of the value in the results grid.
        Returns:
        the value of the property
      • getResult

        public Result<?> getResult()
        Gets the result of the calculation.

        The result may be a single value or a multi-scenario value. A multi-scenario value will implement ScenarioArray unless it has been aggregated.

        If the calculation did not complete successfully, a failure result will be returned explaining the problem. Callers must check whether the result is a success or failure before examining the result value.

        Returns:
        the value of the property, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object