Class ServiceOutcomeImpl<T>

java.lang.Object
com.atlassian.jira.bc.ServiceResultImpl
com.atlassian.jira.bc.ServiceOutcomeImpl<T>
All Implemented Interfaces:
ServiceOutcome<T>, ServiceResult, Serializable
Direct Known Subclasses:
ServiceOutcomeWithWarnings

public class ServiceOutcomeImpl<T> extends ServiceResultImpl implements ServiceOutcome<T>
Generic service outcome that can optionally hold a value.
Since:
v4.2
See Also:
  • Constructor Details

    • ServiceOutcomeImpl

      public ServiceOutcomeImpl(ErrorCollection errorCollection)
      Creates a new ServiceOutcomeImpl with the given errors. The returned value will be set to null.
      Parameters:
      errorCollection - an ErrorCollection
    • ServiceOutcomeImpl

      public ServiceOutcomeImpl(ErrorCollection errorCollection, T value)
      Creates a new ServiceOutcomeImpl with the given errors and returned value.
      Parameters:
      errorCollection - an ErrorCollection
      value - the wrapped value
  • Method Details

    • ok

      public static <T> ServiceOutcomeImpl<T> ok(T returnedValue)
      Convenience method that returns a new ServiceOutcomeImpl instance containing no errors, and with the provided returned value.
      Type Parameters:
      T - the type of the returned value
      Parameters:
      returnedValue - the returned value
      Returns:
      a new ServiceOutcomeImpl
    • error

      public static <T> ServiceOutcomeImpl<T> error(ServiceOutcome<?> outcome)
      Convenience method that returns a new ServiceOutcomeImpl instance with the errors from the passed outcome.
      Type Parameters:
      T - the type of the returned value
      Parameters:
      outcome - the outcome whose errors we are taking.
      Returns:
      a new ServiceOutcomeImpl
    • error

      public static <T> ServiceOutcomeImpl<T> error(String errorMessage)
      Convenience method that returns a new ServiceOutcomeImpl instance containing the provided error message, and no return value.
      Type Parameters:
      T - the type of the returned value
      Parameters:
      errorMessage - the error message to include in the ServiceOutcomeImpl
      Returns:
      a new ServiceOutcomeImpl
    • error

      public static <T> ServiceOutcomeImpl<T> error(String errorMessage, ErrorCollection.Reason reason)
      Convenience method that returns a new ServiceOutcomeImpl instance containing the provided error message, and no return value.
      Type Parameters:
      T - the type of the returned value
      Parameters:
      reason - for the error.
      errorMessage - the error message to include in the ServiceOutcomeImpl
      Returns:
      a new ServiceOutcomeImpl
    • from

      public static <T> ServiceOutcomeImpl<T> from(ErrorCollection errorCollection, T value)
      Convenience method that returns a new ServiceOutcomeImpl containing the given errors and returned value.
      Type Parameters:
      T - the type of the returned value
      Parameters:
      errorCollection - an ErrorCollection
      value - the returned value
      Returns:
      a new ServiceOutcomeImpl instance
    • from

      public static <T> ServiceOutcomeImpl<T> from(ErrorCollection errorCollection)
      Convenience method that returns a new ServiceOutcomeImpl containing the given errors and null return value.
      Type Parameters:
      T - the type of the returned value
      Parameters:
      errorCollection - an ErrorCollection
      Returns:
      a new ServiceOutcomeImpl instance
    • getReturnedValue

      @Nullable public T getReturnedValue()
      Returns the value that was returned by the service, or null.
      Specified by:
      getReturnedValue in interface ServiceOutcome<T>
      Returns:
      the value returned by the service, or null
    • get

      @Nullable public T get()
      Returns the value that was returned by the service, or null.
      Specified by:
      get in interface ServiceOutcome<T>
      Returns:
      the value returned by the service, or null