Class Results

  • All Implemented Interfaces:
    Bean, ImmutableBean

    public final class Results
    extends java.lang.Object
    implements 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Results.Meta
      The meta-bean for Results.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      Result<?> get​(int rowIndex, int columnIndex)
      Returns the results for a target and column index.
      <T> Result<T> get​(int rowIndex, int columnIndex, java.lang.Class<T> type)
      Returns the results for a target and column index, casting the result to a known type.
      Result<?> get​(int rowIndex, ColumnName columnName)
      Returns the results for a target and column name.
      <T> Result<T> get​(int rowIndex, ColumnName columnName, java.lang.Class<T> type)
      Returns the results for a target and column name, casting the result to a known type.
      com.google.common.collect.ImmutableList<Result<?>> getCells()
      Gets the grid of results, stored as a flat list.
      int getColumnCount()
      Gets the number of columns in the results.
      com.google.common.collect.ImmutableList<ColumnHeader> getColumns()
      Gets the column headers.
      int getRowCount()
      Gets the number of rows in the results.
      int hashCode()  
      static Results.Meta meta()
      The meta-bean for Results.
      Results.Meta metaBean()  
      static Results of​(java.util.List<ColumnHeader> columns, java.util.List<? extends Result<?>> cells)
      Obtains an instance containing the results of the calculation for each cell.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • of

        public static Results of​(java.util.List<ColumnHeader> columns,
                                 java.util.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:
        java.lang.IllegalArgumentException - if the row or column index is invalid
      • get

        public <T> Result<T> get​(int rowIndex,
                                 int columnIndex,
                                 java.lang.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:
        java.lang.IllegalArgumentException - if the row or column index is invalid
        java.lang.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:
        java.lang.IllegalArgumentException - if the row index or column name is invalid
      • get

        public <T> Result<T> get​(int rowIndex,
                                 ColumnName columnName,
                                 java.lang.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:
        java.lang.IllegalArgumentException - if the row index or column name is invalid
        java.lang.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
      • getColumns

        public com.google.common.collect.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 com.google.common.collect.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
      • 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