Class ProviderOutcome

java.lang.Object
org.apache.sling.scripting.sightly.use.ProviderOutcome

public final class ProviderOutcome extends Object
Result returned by a UseProvider.
  • Method Details

    • success

      public static ProviderOutcome success(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 specific 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.
      Returns:
      a failed outcome
    • failure

      public static ProviderOutcome failure(Throwable cause)
      Create a failed outcome with the given 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.
      Parameters:
      cause - The reason for this failure, which may be null
      Returns:
      a failed outcome
    • notNullOrFailure

      public static ProviderOutcome notNullOrFailure(Object obj)
      If the given obj is not null return a successful outcome, with the given result. Otherwise, return failure().
      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 Object getResult()
      Get the result in this outcome.
      Returns:
      the result of the container
      Throws:
      IllegalStateException - if the outcome is a failure
    • getCause

      public 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.
      Returns:
      the cause for this failure outcome.