public final class DataResult
extends java.lang.Object
A DataResult represents the result of attempting to load data from a data source.
Such an attempt may result in either failure or success.
If the result is failure,
the plugin must provide a detailed failure message
by calling the failure(String) method.
Otherwise, the plugin should provide a list of the columns retrieved from the data source
by calling the success(List) method.
The success or failure of a result can be determined via the isSuccess() method,
and the relevant fields can be extracted via result() and error().
If the “wrong”method is called—for example,
if the result was actually failure but you call result()—then
the method will raise a NoSuchElementException.
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
error()
Get the error message associated with this result,
asserting that it failed.
|
static DataResult |
failure(java.lang.String error)
Create a result that indicates that
the data retrieval failed to complete
because of the given reason.
|
boolean |
isSuccess()
Determine whether this represents a successful computation.
|
java.util.List<Column> |
result()
Get the list of columns associated with this result,
asserting that it is successful.
|
static DataResult |
success(java.util.List<Column> columns)
Create a result that indicates that
the data retrieval completed successfully
and returned the provided list of columns.
|
public static DataResult success(java.util.List<Column> columns)
columns - the list of columns containing the data that was retrievedDataResult to represent the result of the successful computationjava.lang.NullPointerException - if columns == nullpublic static DataResult failure(java.lang.String error)
error - a detailed message describing the source of the errorDataResult to represent the result of the failed computationjava.lang.NullPointerException - if error == nullpublic boolean isSuccess()
success(List),
the method will return true;
if it was created via failure(String),
the method will return false.true if this represents a successful computation,
or false if it represents a failed computationpublic java.util.List<Column> result() throws java.util.NoSuchElementException
isSuccess().java.util.NoSuchElementException - if this computation was not successfulisSuccess()public java.lang.String error()
throws java.util.NoSuchElementException
isSuccess().java.util.NoSuchElementException - if this computation was successfulisSuccess()