Interface ServiceOutcome<T>
- All Superinterfaces:
ServiceResult
- All Known Implementing Classes:
ServiceOutcomeImpl
An outcome from service which contains either value or validation errors.
- Since:
- 6.7
-
Method Summary
-
Method Details
-
isValid
boolean isValid()- Specified by:
isValid
in interfaceServiceResult
- Returns:
- true if there are no errors, false otherwise.
-
isInvalid
boolean isInvalid()- Specified by:
isInvalid
in interfaceServiceResult
- Returns:
- true if there are errors, false otherwise.
-
getErrors
- Specified by:
getErrors
in interfaceServiceResult
- Returns:
- an
ErrorCollection
that contains any errors that happened as a result of the validations.
-
getValue
- Returns:
- the value that was returned by the service, or throws an
NoSuchElementException
if outcome is non valid.
-
get
Deprecated.usegetValue()
- Returns:
- the value that was returned by the service, or throws an
NoSuchElementException
if outcome is non valid.
-
fold
If the ServiceOutcome is valid, apply the on success function, otherwise apply the error function.- Type Parameters:
B
- the result type- Parameters:
onErrorFunction
- function executed if ServiceOutcome is invalid.onSuccessFunction
- function executed if ServiceOutcome in valid.- Returns:
- the value returned by either or .
-
getValue()