com.atlassian.jira.bc
Class ServiceOutcomeImpl<T>

java.lang.Object
  extended by com.atlassian.jira.bc.ServiceResultImpl
      extended by com.atlassian.jira.bc.ServiceOutcomeImpl<T>
All Implemented Interfaces:
ServiceOutcome<T>, ServiceResult

public class ServiceOutcomeImpl<T>
extends ServiceResultImpl
implements ServiceOutcome<T>

Generic service outcome that can optionally hold a value.

Since:
v4.2

Constructor Summary
ServiceOutcomeImpl(ErrorCollection errorCollection)
          Creates a new ServiceOutcomeImpl with the given errors.
ServiceOutcomeImpl(ErrorCollection errorCollection, T value)
          Creates a new ServiceOutcomeImpl with the given errors and returned value.
 
Method Summary
static
<T> ServiceOutcomeImpl<T>
error(ServiceOutcome<?> outcome)
          Convenience method that returns a new ServiceOutcomeImpl instance with the errors from the passed outcome.
static
<T> ServiceOutcomeImpl<T>
error(String errorMessage)
          Convenience method that returns a new ServiceOutcomeImpl instance containing the provided error message, and no return value.
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.
static
<T> ServiceOutcomeImpl<T>
from(ErrorCollection errorCollection)
          Convenience method that returns a new ServiceOutcomeImpl containing the given errors and null return value.
static
<T> ServiceOutcomeImpl<T>
from(ErrorCollection errorCollection, T value)
          Convenience method that returns a new ServiceOutcomeImpl containing the given errors and returned value.
 T get()
          Returns the value that was returned by the service, or null.
 T getReturnedValue()
          Returns the value that was returned by the service, or null.
static
<T> ServiceOutcomeImpl<T>
ok(T returnedValue)
          Convenience method that returns a new ServiceOutcomeImpl instance containing no errors, and with the provided returned value.
 
Methods inherited from class com.atlassian.jira.bc.ServiceResultImpl
getErrorCollection, isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.bc.ServiceResult
getErrorCollection, isValid
 

Constructor Detail

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 Detail

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

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

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


Copyright © 2002-2014 Atlassian. All Rights Reserved.