Class BooleanAdapter
java.lang.Object
com.github.kaktushose.jda.commands.dispatching.adapter.impl.BooleanAdapter
- All Implemented Interfaces:
TypeAdapter<Boolean>
,BiFunction<String,
GenericInteractionCreateEvent, Optional<Boolean>>
Type adapter for boolean values.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(@NotNull String raw, @NotNull GenericInteractionCreateEvent event) Attempts to parse a String to a Boolean.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.function.BiFunction
andThen
-
Constructor Details
-
BooleanAdapter
public BooleanAdapter()
-
-
Method Details
-
apply
@NotNull public @NotNull Optional<Boolean> apply(@NotNull @NotNull String raw, @NotNull @NotNull GenericInteractionCreateEvent event) Attempts to parse a String to a Boolean. Accepts both String literals and0
or1
. Parsing is case-insensitive.- Specified by:
apply
in interfaceBiFunction<String,
GenericInteractionCreateEvent, Optional<Boolean>> - Specified by:
apply
in interfaceTypeAdapter<Boolean>
- Parameters:
raw
- the String to parseevent
- theGenericInteractionCreateEvent
- Returns:
- the parsed boolean or an empty Optional if the parsing fails
-