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(java.lang.String errorMessage)
          Convenience method that returns a new ServiceOutcomeImpl instance containing the provided error message, and no return value.
 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(java.lang.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

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


Copyright © 2002-2010 Atlassian. All Rights Reserved.