Package com.scytales.mvalid.sdk
Interface Received
-
- All Implemented Interfaces:
public interface Received<D>
The interface Received.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
Received.Success
The interface Success.
public interface
Received.Failure
The interface Failure.
-
Method Summary
-
-
Method Detail
-
success
static <D> Received.Success<D> success(D data)
Creates a Success instance
- Parameters:
data
- the data
-
failure
static <D> Received.Failure<D> failure(@NonNull() FailureType type, @Nullable() String message)
Creates a Failure instance
- Parameters:
type
- the typemessage
- the message
-
failure
static <D> Received.Failure<D> failure(@NonNull() FailureType type)
Create a failure.
- Parameters:
type
- the type
-
run
void run(@NonNull() Consumer<Received.Failure<D>> onFailure, @NonNull() Consumer<D> onSuccess)
Consume Failure or Success
- Parameters:
onFailure
- the on failureonSuccess
- the on success
-
runOnSuccess
Received<D> runOnSuccess(@NonNull() Consumer<D> consumer)
- Parameters:
consumer
- consumes success contents
-
runOnFailure
Received<D> runOnFailure(@NonNull() Consumer<Received.Failure<D>> consumer)
- Parameters:
consumer
- consumes Failure
-
runCatching
void runCatching(@NonNull() Functions.FailableConsumer<Received.Failure<D>, Exception> onFailure, @NonNull() Functions.FailableConsumer<D, Exception> onSuccess)
Consumes Received instances.
- Parameters:
onFailure
- consumer to run on failureonSuccess
- consumer to run on success
-
runOnSuccessCatching
Received<D> runOnSuccessCatching(@NonNull() Functions.FailableConsumer<D, Exception> consumer)
Consume Received data when is Success
- Parameters:
consumer
- consumes received data
-
runOnFailureCatching
Received<D> runOnFailureCatching(@NonNull() Functions.FailableConsumer<Received.Failure<D>, Exception> consumer)
Consume Received data when is Failure
- Parameters:
consumer
- consumes Failure
-
-
-
-