public class Callback
extends java.lang.Object
This is most visibly implemented in
IPCClient.
| Constructor and Description |
|---|
Callback()
Constructs an empty Callback.
|
Callback(java.util.function.Consumer<java.lang.String> failure)
Constructs a Callback with a failure
Consumer that occurs when the
process it is attached to encounters an error, and whose parameter is the
error message. |
Callback(java.lang.Runnable success)
Constructs a Callback with a success
Runnable that occurs when the
process it is attached to executes without error. |
Callback(java.lang.Runnable success,
java.util.function.Consumer<java.lang.String> failure)
Constructs a Callback with a success
Runnable and a failure
Consumer that occurs when the process it is attached to executes
without or with error (respectively). |
| Modifier and Type | Method and Description |
|---|---|
void |
fail(java.lang.String message)
Launches the failure
Consumer with the provided message. |
boolean |
isEmpty()
Gets whether or not this Callback is "empty" which is more precisely defined
as not having a specified success
Runnable and/or a failure
Consumer. |
void |
succeed()
Launches the success
Runnable. |
public Callback()
public Callback(java.lang.Runnable success)
Runnable that occurs when the
process it is attached to executes without error.success - The Runnable to launch after a successful process.public Callback(java.util.function.Consumer<java.lang.String> failure)
Consumer that occurs when the
process it is attached to encounters an error, and whose parameter is the
error message.failure - The Consumer to launch if the process has an error.public Callback(java.lang.Runnable success,
java.util.function.Consumer<java.lang.String> failure)
Runnable and a failure
Consumer that occurs when the process it is attached to executes
without or with error (respectively).success - The Runnable to launch after a successful process.failure - The Consumer to launch if the process has an error.public boolean isEmpty()
Runnable and/or a failure
Consumer.Callback()) or another constructor that leaves one or
both parameters null.true if and only if thepublic void succeed()
Runnable.public void fail(java.lang.String message)
Consumer with the provided message.message - The message to launch the failure consumer with.