Class CharacterAdapter
java.lang.Object
com.github.kaktushose.jda.commands.dispatching.adapter.impl.CharacterAdapter
- All Implemented Interfaces:
TypeAdapter<Character>
,BiFunction<String,
GenericInteractionCreateEvent, Optional<Character>>
Type adapter for character values.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(@NotNull String raw, @NotNull GenericInteractionCreateEvent event) Casts a String to a Char if and only ifraw.length == 1
.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
-
CharacterAdapter
public CharacterAdapter()
-
-
Method Details
-
apply
@NotNull public @NotNull Optional<Character> apply(@NotNull @NotNull String raw, @NotNull @NotNull GenericInteractionCreateEvent event) Casts a String to a Char if and only ifraw.length == 1
. Else, returns an empty Optional.- Specified by:
apply
in interfaceBiFunction<String,
GenericInteractionCreateEvent, Optional<Character>> - Specified by:
apply
in interfaceTypeAdapter<Character>
- Parameters:
raw
- the String to parseevent
- theGenericInteractionCreateEvent
- Returns:
- the parsed Char or an empty Optional if the parsing fails
-