Package eu.mihosoft.devcom
Class Command.Builder<T>
java.lang.Object
eu.mihosoft.devcom.Command.Builder<T>
- Type Parameters:
T
-
Command builder.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates a new command.withOnCancellationRequested
(Consumer<String> onCancellationRequested) withOnError
(BiConsumer<T, Exception> onError) withOnReceived
(Consumer<T> onReceived) withOnSent
(Consumer<T> onSent) withReplyExpected
(boolean replyExpected)
-
Method Details
-
withData
- Parameters:
data
- data to be sent by the command- Returns:
- this builder
-
withOnSent
- Parameters:
onSent
- called if/when the data has been sent (may benull
).- Returns:
- this builder
-
withOnReceived
- Parameters:
onReceived
- called if/when the data has been received (may benull
).- Returns:
- this builder
-
withReplyExpected
- Parameters:
replyExpected
- defines whether a reply is expected.- Returns:
- this builder
-
withOnError
- Parameters:
onError
- error handler is called whenever an error occurs (may benull
).- Returns:
- this builder
-
withOnCancellationRequested
- Parameters:
onCancellationRequested
- handler is called if cancellation is requested (may benull
).- Returns:
- this builder
-
build
Creates a new command.- Returns:
- new command
-