Package com.atlassian.greenhopper.api
Class ResultFactory
java.lang.Object
com.atlassian.greenhopper.api.ResultFactory
Factory for constructing service results in our API.
- Since:
- v5.8.1
- Author:
- mtokar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T,
S> com.atlassian.jira.bc.ServiceOutcome <T> makeJiraErrorOutcome
(ServiceOutcome<S> serviceOutcome, com.atlassian.jira.user.ApplicationUser user) Constructs an invalidServiceOutcome
from a invalidServiceOutcome
.<T> com.atlassian.jira.bc.ServiceOutcome
<T> makeJiraOutcome
(ServiceOutcome<T> serviceOutcome, com.atlassian.jira.user.ApplicationUser user) Constructs aServiceOutcome
from aServiceOutcome
.<T> com.atlassian.jira.bc.ServiceOutcome
<T> makeOkOrNotFoundResult
(T payload, String notFoundErrorMessageKey) Constructs aServiceOutcome
result from a payload and a error message.
-
Constructor Details
-
ResultFactory
public ResultFactory()
-
-
Method Details
-
makeOkOrNotFoundResult
public <T> com.atlassian.jira.bc.ServiceOutcome<T> makeOkOrNotFoundResult(@Nullable T payload, String notFoundErrorMessageKey) Constructs aServiceOutcome
result from a payload and a error message. The error message together with a NOT_FOUND reason is returned in case the payload is null, otherwise a successfuly outcome is returned.- Type Parameters:
T
- the type of the payload- Parameters:
payload
- the payload from the service operation- Returns:
- a result which either contains errors or the payload.
-
makeJiraOutcome
public <T> com.atlassian.jira.bc.ServiceOutcome<T> makeJiraOutcome(ServiceOutcome<T> serviceOutcome, com.atlassian.jira.user.ApplicationUser user) Constructs aServiceOutcome
from aServiceOutcome
. The messages of the error collection are translated into the specified user's locale.- Type Parameters:
T
- the type of the payload- Parameters:
serviceOutcome
- the outcome from greenhopper serviceuser
- the user who performed the service operation- Returns:
- a result which either contains errors or the payload
-
makeJiraErrorOutcome
public <T,S> com.atlassian.jira.bc.ServiceOutcome<T> makeJiraErrorOutcome(ServiceOutcome<S> serviceOutcome, com.atlassian.jira.user.ApplicationUser user) Constructs an invalidServiceOutcome
from a invalidServiceOutcome
. Because they both have only errors, the returned outcome can have different type.- Type Parameters:
T
- the type of the returnedServiceOutcome
S
- the type of the invalidServiceOutcome
- Parameters:
serviceOutcome
- an invalid service outcomeuser
- the user who performed the service operation, need for needed for internationalisation- Returns:
- an invalid
ServiceOutcome
-