Package com.atlassian.jira.bc
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
Generic service outcome that can optionally hold a value.
- Since:
- v4.2
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionServiceOutcomeImpl
(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
Modifier and TypeMethodDescriptionstatic <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>
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.get()
Returns the value that was returned by the service, or null.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, getWarningCollection, 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.ServiceOutcome
fold
Methods inherited from interface com.atlassian.jira.bc.ServiceResult
getErrorCollection, getWarningCollection, hasWarnings, isValid
-
Constructor Details
-
ServiceOutcomeImpl
Creates a new ServiceOutcomeImpl with the given errors. The returned value will be set to null.- Parameters:
errorCollection
- an ErrorCollection
-
ServiceOutcomeImpl
Creates a new ServiceOutcomeImpl with the given errors and returned value.- Parameters:
errorCollection
- an ErrorCollectionvalue
- the wrapped value
-
-
Method Details
-
ok
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
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
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
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
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 ErrorCollectionvalue
- the returned value- Returns:
- a new ServiceOutcomeImpl instance
-
from
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
Returns the value that was returned by the service, or null.- Specified by:
getReturnedValue
in interfaceServiceOutcome<T>
- Returns:
- the value returned by the service, or null
-
get
Returns the value that was returned by the service, or null.- Specified by:
get
in interfaceServiceOutcome<T>
- Returns:
- the value returned by the service, or null
-