Package com.mrivanplays.jdcf.args
Class RestArgumentAction
- java.lang.Object
-
- com.mrivanplays.jdcf.args.RestArgumentAction
-
public final class RestArgumentAction extends java.lang.Object
Represents a rest action, which comes role when the argument you wanted to get back in the code chain is null. This provides aorElse(Consumer)
method, which is being called only when there was no value present back.
-
-
Constructor Summary
Constructors Constructor Description RestArgumentAction(FailReason failReason, java.lang.String argument)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
actionTook()
Returns whenever an action was took on the rest argument or not.void
orElse(@NotNull java.lang.Runnable runnable)
The specifiedRunnable
gets invoked whatever theFailReason
was when the value wasn't present.void
orElse(@NotNull java.util.function.BiConsumer<FailReason,java.lang.String> toRun)
void
orElse(@NotNull java.util.function.Consumer<FailReason> toRun)
The specifiedConsumer
gets invoked with theFailReason
when the value wasn't present.boolean
wasValuePresent()
Returns whenever the value was present.
-
-
-
Constructor Detail
-
RestArgumentAction
public RestArgumentAction(FailReason failReason, java.lang.String argument)
-
-
Method Detail
-
wasValuePresent
public boolean wasValuePresent()
Returns whenever the value was present.- Returns:
true
if present,false
otherwise
-
orElse
public void orElse(@NotNull @NotNull java.util.function.Consumer<FailReason> toRun)
The specifiedConsumer
gets invoked with theFailReason
when the value wasn't present.- Parameters:
toRun
- the action to run
-
orElse
public void orElse(@NotNull @NotNull java.util.function.BiConsumer<FailReason,java.lang.String> toRun)
The specifiedBiConsumer
gets invoked with theFailReason
and the specifiedString
argument. Depending on the fail reason, the argument may or may not be null.- Parameters:
toRun
- the action to run
-
actionTook
public boolean actionTook()
Returns whenever an action was took on the rest argument or not.- Returns:
true
if action took,false
if not
-
orElse
public void orElse(@NotNull @NotNull java.lang.Runnable runnable)
The specifiedRunnable
gets invoked whatever theFailReason
was when the value wasn't present.- Parameters:
runnable
- the runnable to run
-
-