Class CalculationResult

  • All Implemented Interfaces:
    Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class CalculationResult
    extends Object
    implements org.joda.beans.ImmutableBean, 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​(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:
        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
      • meta

        public static org.joda.beans.TypedMetaBean<CalculationResult> meta()
        The meta-bean for CalculationResult.
        Returns:
        the meta-bean, not null
      • metaBean

        public org.joda.beans.TypedMetaBean<CalculationResult> metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object