Class Runnables
java.lang.Object
ru.progrm_jarvis.javacommons.util.function.Runnables
Utilities related to
runnables.-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull RunnabledoubleStateful(double initialState, @NonNull DoubleUnaryOperator handler) Creates a stateful runnable which stores its state immutably.static @NotNull RunnableintStateful(int initialState, @NonNull IntUnaryOperator handler) Creates a stateful runnable which stores its state immutably.static @NotNull RunnablelongStateful(long initialState, @NonNull LongUnaryOperator handler) Creates a stateful runnable which stores its state immutably.static @NotNull Runnablenone()Creates a runnable which does nothing.static <T> @NotNull RunnableCreates a stateful runnable which stores its state immutably.
-
Method Details
-
none
Creates a runnable which does nothing.- Returns:
- runnable which does nothing
-
stateful
@NotNull public static <T> @NotNull Runnable stateful(T initialState, @NonNull @NonNull Function<? super T, ? extends T> handler) Creates a stateful runnable which stores its state immutably.- Type Parameters:
T- type of stored state- Parameters:
initialState- initial state of the created runnablehandler- handler invoked on each call toRunnable.run()with the state applied to it providing the new state- Returns:
- created stateful runnable
- Throws:
NullPointerException- ifhandlerisnull
-
intStateful
@NotNull public static @NotNull Runnable intStateful(int initialState, @NonNull @NonNull IntUnaryOperator handler) Creates a stateful runnable which stores its state immutably.- Parameters:
initialState- initial state of the created runnablehandler- handler invoked on each call toRunnable.run()with the state applied to it providing the new state- Returns:
- created stateful runnable
- Throws:
NullPointerException- ifhandlerisnull
-
longStateful
@NotNull public static @NotNull Runnable longStateful(long initialState, @NonNull @NonNull LongUnaryOperator handler) Creates a stateful runnable which stores its state immutably.- Parameters:
initialState- initial state of the created runnablehandler- handler invoked on each call toRunnable.run()with the state applied to it providing the new state- Returns:
- created stateful runnable
- Throws:
NullPointerException- ifhandlerisnull
-
doubleStateful
@NotNull public static @NotNull Runnable doubleStateful(double initialState, @NonNull @NonNull DoubleUnaryOperator handler) Creates a stateful runnable which stores its state immutably.- Parameters:
initialState- initial state of the created runnablehandler- handler invoked on each call toRunnable.run()with the state applied to it providing the new state- Returns:
- created stateful runnable
- Throws:
NullPointerException- ifhandlerisnull
-