public final class ProviderOutcome extends Object
UseProvider
.Modifier and Type | Method and Description |
---|---|
static ProviderOutcome |
failure()
Create a failed outcome without a specific
cause . |
static ProviderOutcome |
failure(Throwable cause)
Create a failed outcome with the given
cause . |
Throwable |
getCause()
Returns the cause for this failure outcome or
null if this outcome is a success or no cause has been defined with the
failure(Throwable) method. |
Object |
getResult()
Get the result in this outcome.
|
boolean |
isFailure()
Check whether the outcome is a failure
|
boolean |
isSuccess()
Check if the outcome has been successful
|
static ProviderOutcome |
notNullOrFailure(Object obj)
If the given obj is not
null return a successful outcome , with the given result. |
static ProviderOutcome |
success(Object result)
Create a successful outcome
|
public static ProviderOutcome success(Object result)
result
- the resultpublic static ProviderOutcome failure()
cause
. This method must be used for creating outcomes that don't
signal an error but rather the fact that the UseProvider
is not capable of fulfilling the request.public static ProviderOutcome failure(Throwable cause)
cause
. This method must be used when the UseProvider
is
capable of fulfilling the request but an error condition prevents the provider from doing so.cause
- The reason for this failure, which may be null
public static ProviderOutcome notNullOrFailure(Object obj)
null
return a successful outcome
, with the given result. Otherwise, return
failure()
.obj
- the resultpublic boolean isSuccess()
public boolean isFailure()
public Object getResult()
IllegalStateException
- if the outcome is a failurepublic Throwable getCause()
null
if this outcome is a success or no cause has been defined with the
failure(Throwable)
method.Copyright © 2017 The Apache Software Foundation. All rights reserved.