Class Results

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

    public final class Results
    extends Object
    implements org.joda.beans.ImmutableBean
    Calculation results of performing calculations for a set of targets and columns.

    This defines a grid of results where the grid contains a row for each target and a column for each measure. Each result may be a single value or a multi-scenario value. A multi-scenario value will implement ScenarioArray unless it has been aggregated.

    • Method Detail

      • of

        public static Results of​(List<ColumnHeader> columns,
                                 List<? extends Result<?>> cells)
        Obtains an instance containing the results of the calculation for each cell.

        The number of cells must be exactly divisible by the number of columns.

        Parameters:
        columns - the names of each column
        cells - the calculated results, one for each cell
        Returns:
        a set of results for the calculations
      • getRowCount

        public int getRowCount()
        Gets the number of rows in the results.

        The number of rows equals the number of targets input to the calculation.

        Returns:
        the number of rows
      • getColumnCount

        public int getColumnCount()
        Gets the number of columns in the results.
        Returns:
        the number of columns
      • get

        public Result<?> get​(int rowIndex,
                             int columnIndex)
        Returns the results for a target and column index.

        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.

        Parameters:
        rowIndex - the index of the row containing the results for a target
        columnIndex - the index of the column
        Returns:
        the result for the specified row and column for a set of scenarios
        Throws:
        IllegalArgumentException - if the row or column index is invalid
      • get

        public <T> Result<T> get​(int rowIndex,
                                 int columnIndex,
                                 Class<T> type)
        Returns the results for a target and column index, 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:
        rowIndex - the index of the row containing the results for a target
        columnIndex - the index of the column
        type - the result type
        Returns:
        the result for the specified row and column for a set of scenarios, cast to the specified type
        Throws:
        IllegalArgumentException - if the row or column index is invalid
        ClassCastException - if the result is not of the specified type
      • get

        public Result<?> get​(int rowIndex,
                             ColumnName columnName)
        Returns the results for a target and column name.

        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.

        Parameters:
        rowIndex - the index of the row containing the results for a target
        columnName - the name of the column
        Returns:
        the result for the specified row and column for a set of scenarios
        Throws:
        IllegalArgumentException - if the row index or column name is invalid
      • get

        public <T> Result<T> get​(int rowIndex,
                                 ColumnName columnName,
                                 Class<T> type)
        Returns the results for a target and column name, 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:
        rowIndex - the index of the row containing the results for a target
        columnName - the name of the column
        type - the result type
        Returns:
        the result for the specified row and column for a set of scenarios, cast to the specified type
        Throws:
        IllegalArgumentException - if the row index or column name is invalid
        ClassCastException - if the result is not of the specified type
      • meta

        public static Results.Meta meta()
        The meta-bean for Results.
        Returns:
        the meta-bean, not null
      • metaBean

        public Results.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getColumns

        public ImmutableList<ColumnHeader> getColumns()
        Gets the column headers.

        Each column in the results is defined by a header consisting of the name and measure. The size of this list defines the number of columns, which is needed to interpret the list of cells.

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

        public ImmutableList<Result<?>> getCells()
        Gets the grid of results, stored as a flat list.

        This list contains the calculated result for each cell in the grid. The cells are grouped by target, then column. Thus, the index of a given cell is (targetRowIndex * columnCount) + columnIndex.

        For example, given a set of results with two targets, t1 and t2, and three columns c1, c2, and c3, the results will be:

         [t1c1, t1c2, t1c3, t2c1, t2c2, t2c3]
         
        Returns:
        the value of the property, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object