Class ProviderOutcome
java.lang.Object
org.apache.sling.scripting.sightly.use.ProviderOutcome
Result returned by a
UseProvider
.-
Method Summary
Modifier and TypeMethodDescriptionstatic ProviderOutcome
failure()
Create a failed outcome without a specificcause
.static ProviderOutcome
Create a failed outcome with the givencause
.getCause()
Returns the cause for this failure outcome ornull
if this outcome is a success or no cause has been defined with thefailure(Throwable)
method.Get the result in this outcome.boolean
Check whether the outcome is a failureboolean
Check if the outcome has been successfulstatic ProviderOutcome
notNullOrFailure
(Object obj) If the given obj is notnull
return asuccessful outcome
, with the given result.static ProviderOutcome
Create a successful outcome
-
Method Details
-
success
Create a successful outcome- Parameters:
result
- the result- Returns:
- a successful result
-
failure
Create a failed outcome without a specificcause
. This method must be used for creating outcomes that don't signal an error but rather the fact that theUseProvider
is not capable of fulfilling the request.- Returns:
- a failed outcome
-
failure
Create a failed outcome with the givencause
. This method must be used when theUseProvider
is capable of fulfilling the request but an error condition prevents the provider from doing so.- Parameters:
cause
- The reason for this failure, which may benull
- Returns:
- a failed outcome
-
notNullOrFailure
If the given obj is notnull
return asuccessful outcome
, with the given result. Otherwise, returnfailure()
.- Parameters:
obj
- the result- Returns:
- an outcome based on whether the parameter is null or not
-
isSuccess
public boolean isSuccess()Check if the outcome has been successful- Returns:
- the outcome success status
-
isFailure
public boolean isFailure()Check whether the outcome is a failure- Returns:
- the outcome failure status
-
getResult
Get the result in this outcome.- Returns:
- the result of the container
- Throws:
IllegalStateException
- if the outcome is a failure
-
getCause
Returns the cause for this failure outcome ornull
if this outcome is a success or no cause has been defined with thefailure(Throwable)
method.- Returns:
- the cause for this failure outcome.
-