Class InputProvider<V>
- java.lang.Object
-
- me.nemo_64.betterinputs.api.input.InputProvider<V>
-
public final class InputProvider<V> extends Object
-
-
Constructor Summary
Constructors Constructor Description InputProvider(IPlatformActor<?> actor, TickTimer timer, AbstractInput<V> input, Consumer<Throwable> exceptionHandler, BiConsumer<InputProvider<V>,String> cancelListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StagedFuture<V>
asFuture()
Gets the future of this process and starts the input process on first callboolean
cancel()
Tries to cancel the input processboolean
cancel(String reason)
Tries to cancel the input process with a specified reasonV
get()
Gets the input of this input processIPlatformActor<?>
getActor()
Gets the wrapped owning actor<M extends AbstractModifier<V>>
Optional<M>getModifier(Class<M> modifierType)
Gets an input modifierboolean
hasModifier(Class<? extends AbstractModifier<V>> modifierType)
Checks if a modifier is setboolean
isAvailable()
Checks if the input is available alreadyboolean
isCancelled()
Checks if the input process is cancelledInputProvider<V>
withModifier(AbstractModifier<V> modifier)
Adds a input modifierInputProvider<V>
withModifierExceptionHandler(BiConsumer<AbstractModifier<V>,Throwable> modifierExceptionHandler)
Sets the modifier exception handler
-
-
-
Constructor Detail
-
InputProvider
public InputProvider(IPlatformActor<?> actor, TickTimer timer, AbstractInput<V> input, Consumer<Throwable> exceptionHandler, BiConsumer<InputProvider<V>,String> cancelListener)
-
-
Method Detail
-
asFuture
public StagedFuture<V> asFuture()
Gets the future of this process and starts the input process on first call- Returns:
- the future
-
withModifier
public InputProvider<V> withModifier(AbstractModifier<V> modifier)
Adds a input modifier- Parameters:
modifier
- the modifier to be added- Returns:
- the same input provider
-
getModifier
public <M extends AbstractModifier<V>> Optional<M> getModifier(Class<M> modifierType)
Gets an input modifier- Type Parameters:
M
- the provided modifier type- Parameters:
modifierType
- the input modifier type- Returns:
- an
java.lang.Optional
containing the input modifier ornull
-
hasModifier
public boolean hasModifier(Class<? extends AbstractModifier<V>> modifierType)
Checks if a modifier is set- Parameters:
modifierType
- the modifier type to be checked- Returns:
true
if the modifier type is set otherwisefalse
-
withModifierExceptionHandler
public InputProvider<V> withModifierExceptionHandler(BiConsumer<AbstractModifier<V>,Throwable> modifierExceptionHandler)
Sets the modifier exception handler- Parameters:
modifierExceptionHandler
- the handler to be set- Returns:
- the same input provider
-
cancel
public boolean cancel()
Tries to cancel the input process- Returns:
true
if the process was cancelled otherwisefalse
-
cancel
public boolean cancel(String reason)
Tries to cancel the input process with a specified reason- Parameters:
reason
- the reason why the process was cancelled- Returns:
true
if the process was cancelled otherwisefalse
-
isCancelled
public boolean isCancelled()
Checks if the input process is cancelled- Returns:
true
if process is cancelled otherwisefalse
-
isAvailable
public boolean isAvailable()
Checks if the input is available already- Returns:
true
if the input is available otherwisefalse
-
getActor
public IPlatformActor<?> getActor()
Gets the wrapped owning actor- Returns:
- the actor
-
get
public V get() throws IllegalStateException
Gets the input of this input process- Returns:
- the input provided by the process
- Throws:
IllegalStateException
- if the process isn't done yet
-
-