Class ServiceErrorCollector
java.lang.Object
com.atlassian.greenhopper.service.util.ServiceErrorCollector
This class can be used when multiple validation errors can be returned simultaneously. Errors resulting from
invoking the collect and collectOrGet methods are aggregated, and can be checked using the validate method.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
collect
(ServiceResult result) Checks the given ServiceOutcome, and if it is invalid, adds the errors it contains to this error collector.<T> T
collectOrGet
(ServiceOutcome<T> result) Checks the given ServiceOutcome.<T> T
collectOrGet
(com.atlassian.jira.bc.ServiceOutcome<T> result) Checks the given ServiceOutcome.Returns a value indicating if the last invocation of collect or collectOrGet was invoked on a ServiceOutcome that was valid.void
validate()
Checks if this ErrorCollection contains any errors, and if so, an ServiceOutcomeException is thrown.
-
Constructor Details
-
ServiceErrorCollector
public ServiceErrorCollector()
-
-
Method Details
-
collect
Checks the given ServiceOutcome, and if it is invalid, adds the errors it contains to this error collector. -
collectOrGet
Checks the given ServiceOutcome. If it is valid, the value that it holds is returned. If it is invalid, the errors added to this error collector and null is returned. -
collectOrGet
public <T> T collectOrGet(com.atlassian.jira.bc.ServiceOutcome<T> result) Checks the given ServiceOutcome. If it is valid, the value that it holds is returned. If it is invalid, the errors added to this error collector and null is returned. -
validate
Checks if this ErrorCollection contains any errors, and if so, an ServiceOutcomeException is thrown. The exception thrown contains all the errors that are held by this error collector.- Throws:
ServiceOutcomeException
-
isLastResultValid
Returns a value indicating if the last invocation of collect or collectOrGet was invoked on a ServiceOutcome that was valid. Empty Optional is returned only if there was no previous invocation of collect or collectOrGet.
-