Class DelayedInputRequest<T>
java.lang.Object
nl.pim16aap2.animatedarchitecture.core.util.delayedinput.DelayedInputRequest<T>
- Type Parameters:
T- The type of data to request.
- Direct Known Subclasses:
DelayedCommandInputRequest,DelayedStructureSpecificationInputRequest
Represents a request for delayed input. E.g. by waiting for user input.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the various different stages of a request. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDelayedInputRequest(long timeout, TimeUnit timeUnit) Instantiates a newDelayedInputRequest.protectedDelayedInputRequest(Duration timeout) Instantiates a newDelayedInputRequest. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidcancel()Cancels the request if it is still waiting for input.booleanChecks if the input request was cancelled.protected booleanprotected voidcleanup()Runs after the request has closed.booleanChecks if the input request was completed.booleanbooleanChecks if the request was completed with an exception.protected CompletableFuture<Optional<T>> The result of this input request.Gets the current status of this request.inthashCode()final voidProvides the value that this object is waiting for.booleansuccess()Checks if the request was fulfilled successfully.booleantimedOut()Check if the request timed out while waiting for input.toString()
-
Constructor Details
-
DelayedInputRequest
Instantiates a newDelayedInputRequest.- Parameters:
timeout- The timeout to wait before giving up. Must be larger than 0.timeUnit- The unit of time.
-
DelayedInputRequest
Instantiates a newDelayedInputRequest.- Parameters:
timeout- The amount of time to wait before cancelling the request.
-
-
Method Details
-
cancel
public final void cancel()Cancels the request if it is still waiting for input.Calling this method after the request has already completed has no effect.
See
completed(). -
set
Provides the value that this object is waiting for.Calling this method after the request has already completed has no effect.
See
completed().- Parameters:
value- The new value.
-
cleanup
protected void cleanup()Runs after the request has closed. Either because input was provided or because the request timed out.See
getStatus(). -
cancelled
public boolean cancelled()Checks if the input request was cancelled.- Returns:
- True if the input request was cancelled.
-
completed
public boolean completed()Checks if the input request was completed. This includes via timing out / cancellation / exception / success.- Returns:
- True if the input request was completed.
-
timedOut
public boolean timedOut()Check if the request timed out while waiting for input.- Returns:
- True if the request timed out.
-
exceptionally
public boolean exceptionally()Checks if the request was completed with an exception.- Returns:
- True if the request was completed with an exception.
-
success
public boolean success()Checks if the request was fulfilled successfully.- Returns:
- True if the request was completed successfully.
-
getStatus
Gets the current status of this request.- Returns:
- The current status of this request.
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getInputResult
The result of this input request.
-