|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.greenhopper.service.ServiceOutcomeImpl<T>
public class ServiceOutcomeImpl<T>
Generic service outcome that can optionally hold a value.
Method Summary | ||
---|---|---|
static
|
error(ErrorCollection.Reason reason,
java.lang.String messageKey,
java.lang.Object... params)
Convenience method that returns a new ServiceOutcomeImpl instance containing the provided error message, and no return value. |
|
static
|
error(ServiceOutcome<?> outcome)
Convenience method that returns a new ServiceOutcomeImpl containing the given errors. |
|
static
|
error(java.lang.String contextId,
ErrorCollection.Reason reason,
java.lang.String messageKey,
java.lang.Object... params)
Convenience method that returns a new ServiceOutcomeImpl instance containing the provided contextual error message, and no return value. |
|
|
flatMap(com.google.common.base.Function<? super T,ServiceOutcome<A>> func)
|
|
void |
foreach(com.atlassian.fugue.Effect<T> visitor)
|
|
static
|
from(ErrorCollection errors)
Convenience method that returns a new ServiceOutcomeImpl containing the given errors. |
|
static
|
from(com.atlassian.jira.util.ErrorCollection jiraErrors)
Convenience method that returns a new ServiceOutcomeImpl containing the given errors. |
|
static
|
from(com.atlassian.jira.util.ErrorCollection jiraErrors,
ErrorCollection.Reason reason)
Convenience method that returns a new ServiceOutcomeImpl containing the given errors. |
|
static
|
from(ErrorCollection errors,
T value)
Convenience method that returns a new ServiceOutcomeImpl containing the given errors and returned value. |
|
ErrorCollection |
getErrors()
|
|
T |
getValue()
Returns the value that was returned by the service, or null. |
|
boolean |
isInvalid()
|
|
boolean |
isValid()
|
|
|
map(com.google.common.base.Function<? super T,A> func)
|
|
static
|
ok()
Convenience method that returns a new ServiceOutcomeImpl instance containing no errors, and with the provided returned value. |
|
static
|
ok(T returnedValue)
Convenience method that returns a new ServiceOutcomeImpl instance containing no errors, and with the provided returned value. |
|
com.atlassian.fugue.Either<ErrorCollection,com.atlassian.fugue.Option<T>> |
toEither()
|
|
com.atlassian.fugue.Option<T> |
toOption()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> ServiceOutcomeImpl<T> ok(T returnedValue)
T
- the type of the returned valuereturnedValue
- the returned value
public static <Void> ServiceOutcomeImpl<Void> ok()
Void
- the type of the returned value
public static <T> ServiceOutcomeImpl<T> error(ErrorCollection.Reason reason, java.lang.String messageKey, java.lang.Object... params)
reason
- the reason for the errormessageKey
- the key of the messageparams
- the parameters to the key
public static <T> ServiceOutcomeImpl<T> error(java.lang.String contextId, ErrorCollection.Reason reason, java.lang.String messageKey, java.lang.Object... params)
contextId
- context of the errorreason
- the reason for the errormessageKey
- the key of the messageparams
- the parameters to the key
public static <T> ServiceOutcomeImpl<T> error(ServiceOutcome<?> outcome)
public static <T> ServiceOutcomeImpl<T> from(ErrorCollection errors)
T
- the type of the returned valueerrors
- an ErrorCollection
public static <T> ServiceOutcomeImpl<T> from(com.atlassian.jira.util.ErrorCollection jiraErrors)
T
- the type of the returned valuejiraErrors
- a JIRA ErrorCollection
public static <T> ServiceOutcomeImpl<T> from(com.atlassian.jira.util.ErrorCollection jiraErrors, ErrorCollection.Reason reason)
T
- the type of the returned valuejiraErrors
- a JIRA ErrorCollectionreason
- the reason for the errors
public static <T> ServiceOutcomeImpl<T> from(ErrorCollection errors, T value)
T
- the type of the returned valueerrors
- an ErrorCollectionvalue
- the returned value
public boolean isValid()
isValid
in interface ServiceOutcome<T>
public boolean isInvalid()
isInvalid
in interface ServiceOutcome<T>
public ErrorCollection getErrors()
getErrors
in interface ServiceOutcome<T>
ErrorCollection
that contains any errors that may have happened as a result of the validations.public T getValue()
getValue
in interface ServiceOutcome<T>
public com.atlassian.fugue.Option<T> toOption()
toOption
in interface ServiceOutcome<T>
public com.atlassian.fugue.Either<ErrorCollection,com.atlassian.fugue.Option<T>> toEither()
toEither
in interface ServiceOutcome<T>
public void foreach(com.atlassian.fugue.Effect<T> visitor)
foreach
in interface com.atlassian.fugue.Effect.Applicant<T>
public <A> ServiceOutcome<A> map(com.google.common.base.Function<? super T,A> func)
map
in interface ServiceOutcome<T>
A
- the type of the ServiceOutcomefunc
- a function which takes a instance of type T and returns an instance of type A
public <A> ServiceOutcome<A> flatMap(com.google.common.base.Function<? super T,ServiceOutcome<A>> func)
flatMap
in interface ServiceOutcome<T>
A
- the type of the ServiceOutcomefunc
- a function which takes a instance of type T and returns a ServiceOutcome of type A
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |