-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classResult.SuccessRepresents successful result.
public final classResult.FailureRepresents failed result.
-
Method Summary
Modifier and Type Method Description final BooleanisSuccess()final BooleanisFailure()final AgetOrNull()Returns the encapsulated value if this instance represents Success or nullif it is Failure.final AgetOrThrow()Returns the encapsulated value if this instance represents Success or throws the IllegalStateException exception if it is Failure. final ChatErrorchatErrorOrNull()Returns the encapsulated ChatError if this instance represents Failure or nullif it is Success.final <C extends Any> Result<C>map(Function1<A, C> f)Returns a transformed Result of applying the given f function if the Result contains a successful data payload. final Result<Unit>toUnitResult()Returns a Result of Unit from any type of a Result. final Result<A>onSuccess(Function1<A, Unit> successSideEffect)Runs the successSideEffect lambda function if the Result contains a successful data payload. final Result<A>onError(Function1<ChatError, Unit> errorSideEffect)Runs the errorSideEffect lambda function if the Result contains an error payload. -
-
Method Detail
-
getOrThrow
final A getOrThrow()
Returns the encapsulated value if this instance represents Success or throws the IllegalStateException exception if it is Failure.
-
chatErrorOrNull
final ChatError chatErrorOrNull()
-
toUnitResult
final Result<Unit> toUnitResult()
-
onSuccess
final Result<A> onSuccess(Function1<A, Unit> successSideEffect)
Runs the successSideEffect lambda function if the Result contains a successful data payload.
- Parameters:
successSideEffect- A lambda that receives the successful data payload.
-
-
-
-