Class ProviderOutcome
- java.lang.Object
-
- org.apache.sling.scripting.sightly.use.ProviderOutcome
-
public final class ProviderOutcome extends java.lang.ObjectResult returned by aUseProvider.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ProviderOutcomefailure()Create a failed outcome without a specificcause.static ProviderOutcomefailure(java.lang.Throwable cause)Create a failed outcome with the givencause.java.lang.ThrowablegetCause()Returns the cause for this failure outcome ornullif this outcome is a success or no cause has been defined with thefailure(Throwable)method.java.lang.ObjectgetResult()Get the result in this outcome.booleanisFailure()Check whether the outcome is a failurebooleanisSuccess()Check if the outcome has been successfulstatic ProviderOutcomenotNullOrFailure(java.lang.Object obj)If the given obj is notnullreturn asuccessful outcome, with the given result.static ProviderOutcomesuccess(java.lang.Object result)Create a successful outcome
-
-
-
Method Detail
-
success
public static ProviderOutcome success(java.lang.Object result)
Create a successful outcome- Parameters:
result- the result- Returns:
- a successful result
-
failure
public static ProviderOutcome 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 theUseProvideris not capable of fulfilling the request.- Returns:
- a failed outcome
-
failure
public static ProviderOutcome failure(java.lang.Throwable cause)
Create a failed outcome with the givencause. This method must be used when theUseProvideris 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
public static ProviderOutcome notNullOrFailure(java.lang.Object obj)
If the given obj is notnullreturn 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
public java.lang.Object getResult()
Get the result in this outcome.- Returns:
- the result of the container
- Throws:
java.lang.IllegalStateException- if the outcome is a failure
-
getCause
public java.lang.Throwable getCause()
Returns the cause for this failure outcome ornullif this outcome is a success or no cause has been defined with thefailure(Throwable)method.- Returns:
- the cause for this failure outcome.
-
-