Package com.codebarrel.api
Interface ServiceOutcome<T>
public interface ServiceOutcome<T>
This interface represents a service method call result. A service method call can either completes successfully
and returns some value OR it can fail with one or more errors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ServiceOutcome<T> error(ErrorCollection errorCollection) get()booleanisValid()Did the service method call complete successfully?static <T> ServiceOutcome<T> ok(T value)
-
Method Details
-
isValid
boolean isValid()Did the service method call complete successfully?- Returns:
- true if method call completes successfully, otherwise false.
-
getErrorCollection
ErrorCollection getErrorCollection()- Returns:
ErrorCollectionthat contains any errors that occurred during the service call. The returnedErrorCollectionmay not contain any errors if the method call completes successfully.
-
get
T get()- Returns:
- the value that corresponds to the service method call result.
- Throws:
IllegalStateException- when called on an invalidServiceOutcome
-
error
-
ok
-