Package tech.harmonysoft.oss.common
Class ProcessingResult
-
- All Implemented Interfaces:
public final class ProcessingResult<SUCCESS extends Object, FAILURE extends Object>Quite often we want to return a value of particular type if the processing is successful and a value of another type in case of processing failure. This class allows to handle that, for example, we might have a method which fetches some data and returns it in case of success or returns error description in case of failure. Its return type can be defined as
ProcessingResult<MyData, String>then.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classProcessingResult.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Booleansuccessprivate final SUCCESSsuccessValueprivate final FAILUREfailureValuepublic final static ProcessingResult.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final BooleangetSuccess()final SUCCESSgetSuccessValue()final FAILUREgetFailureValue()final <NEW_SUCCESS extends Any> ProcessingResult<NEW_SUCCESS, FAILURE>mapError()StringtoString()IntegerhashCode()Booleanequals(Object other)-
-
Method Detail
-
getSuccess
final Boolean getSuccess()
-
getSuccessValue
final SUCCESS getSuccessValue()
-
getFailureValue
final FAILURE getFailureValue()
-
mapError
final <NEW_SUCCESS extends Any> ProcessingResult<NEW_SUCCESS, FAILURE> mapError()
-
-
-
-