public final class Results extends Object implements org.joda.beans.ImmutableBean
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
Results.Meta
The meta-bean for
Results. |
| Modifier and Type | Method and Description |
|---|---|
int |
columnIndexByName(ColumnName columnName)
Gets the column index by name.
|
<T> Stream<Result<?>> |
columnResults(int columnIndex)
Returns a stream of results for a single column by column index.
|
<T> Stream<Result<T>> |
columnResults(int columnIndex,
Class<T> type)
Returns a stream of results for a single column by column index.
|
<C> Stream<Result<ScenarioArray<C>>> |
columnResultsScenarios(int columnIndex,
Class<C> componentType)
Returns a stream of multi-scenario results for a single column by column index.
|
boolean |
equals(Object obj) |
Result<?> |
get(int rowIndex,
ColumnName columnName)
Returns the results for a target and column name.
|
<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.
|
Result<?> |
get(int rowIndex,
int columnIndex)
Returns the results for a target and column index.
|
<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.
|
ImmutableList<Result<?>> |
getCells()
Gets the grid of results, stored as a flat list.
|
int |
getColumnCount()
Gets the number of columns in the results.
|
ImmutableList<ColumnHeader> |
getColumns()
Gets the column headers.
|
int |
getRowCount()
Gets the number of rows in the results.
|
<C> Result<ScenarioArray<C>> |
getScenarios(int rowIndex,
ColumnName columnName,
Class<C> componentType)
Returns multi-scenario results for a target and column name, casting the result to a known type.
|
<C> Result<ScenarioArray<C>> |
getScenarios(int rowIndex,
int columnIndex,
Class<C> componentType)
Returns multi-scenario results for a target and column index, casting the result to a known type.
|
int |
hashCode() |
static Results.Meta |
meta()
The meta-bean for
Results. |
Results.Meta |
metaBean() |
static Results |
of(List<ColumnHeader> columns,
List<? extends Result<?>> cells)
Obtains an instance containing the results of the calculation for each cell.
|
String |
toString() |
public static Results of(List<ColumnHeader> columns, List<? extends Result<?>> cells)
The number of cells must be exactly divisible by the number of columns.
columns - the names of each columncells - the calculated results, one for each cellpublic int getRowCount()
The number of rows equals the number of targets input to the calculation.
public int getColumnCount()
public Result<?> get(int rowIndex, int columnIndex)
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.
rowIndex - the index of the row containing the results for a targetcolumnIndex - the index of the columnIllegalArgumentException - if the row or column index is invalidpublic <T> Result<T> get(int rowIndex, int columnIndex, Class<T> 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.
T - the result typerowIndex - the index of the row containing the results for a targetcolumnIndex - the index of the columntype - the result typeIllegalArgumentException - if the row or column index is invalidClassCastException - if the result is not of the specified typepublic Result<?> get(int rowIndex, ColumnName columnName)
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.
rowIndex - the index of the row containing the results for a targetcolumnName - the name of the columnIllegalArgumentException - if the row index or column name is invalidpublic int columnIndexByName(ColumnName columnName)
columnName - the column nameIllegalArgumentException - if the column name is invalidpublic <T> Result<T> get(int rowIndex, ColumnName columnName, Class<T> 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.
T - the result typerowIndex - the index of the row containing the results for a targetcolumnName - the name of the columntype - the result typeIllegalArgumentException - if the row index or column name is invalidClassCastException - if the result is not of the specified typepublic <C> Result<ScenarioArray<C>> getScenarios(int rowIndex, int columnIndex, Class<C> componentType)
The result is a multi-scenario ScenarioArray.
Typed subclasses of ScenarioArray can also be obtained using get(int, int, Class).
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.
C - the type parameter of ScenarioArrayrowIndex - the index of the row containing the results for a targetcolumnIndex - the index of the columncomponentType - the type parameter of ScenarioArrayIllegalArgumentException - if the row or column index is invalidClassCastException - if the result is not of the specified typepublic <C> Result<ScenarioArray<C>> getScenarios(int rowIndex, ColumnName columnName, Class<C> componentType)
The result is a multi-scenario ScenarioArray.
Typed subclasses of ScenarioArray can also be obtained using get(int, ColumnName, Class).
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.
C - the type parameter of ScenarioArrayrowIndex - the index of the row containing the results for a targetcolumnName - the name of the columncomponentType - the type parameter of ScenarioArrayIllegalArgumentException - if the row or column index is invalidClassCastException - if the result is not of the specified typepublic <T> Stream<Result<?>> columnResults(int columnIndex)
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.
Large streams can be processed in parallel via BaseStream.parallel().
See Guavate.zipWithIndex(Stream) if the row index is required.
T - the result typecolumnIndex - the index of the columnIllegalArgumentException - if the column index is invalidpublic <T> Stream<Result<T>> columnResults(int columnIndex, Class<T> 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.
Large streams can be processed in parallel via BaseStream.parallel().
See Guavate.zipWithIndex(Stream) if the row index is required.
The stream will throw ClassCastException if the result is not of the specified type.
T - the result typecolumnIndex - the index of the columntype - the result typeIllegalArgumentException - if the column index is invalidpublic <C> Stream<Result<ScenarioArray<C>>> columnResultsScenarios(int columnIndex, Class<C> componentType)
The result is a multi-scenario ScenarioArray.
Typed subclasses of ScenarioArray can also be obtained using columnResults(int).
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.
Large streams can be processed in parallel via BaseStream.parallel().
See Guavate.zipWithIndex(Stream) if the row index is required.
The stream will throw ClassCastException if the result is not of the specified type.
C - the type parameter of ScenarioArraycolumnIndex - the index of the columncomponentType - the type parameter of ScenarioArrayIllegalArgumentException - if the column index is invalidpublic static Results.Meta meta()
Results.public Results.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic ImmutableList<ColumnHeader> getColumns()
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.
public ImmutableList<Result<?>> getCells()
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]
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.