Class ActionResolver
- java.lang.Object
-
- com.kraken.api.core.interaction.resolver.ActionResolver
-
public final class ActionResolver extends java.lang.ObjectStateless utility for matching action strings against available action arrays.
-
-
Constructor Summary
Constructors Constructor Description ActionResolver()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<MenuOption>findAction(java.lang.String requested, java.lang.String[] available, java.util.function.IntFunction<MenuOption> factory)Finds the first action inavailablematchingrequested, then maps its index throughfactoryto produce a MenuOption.static booleanmatches(java.lang.String requested, java.lang.String candidate)Compares a requested string with a candidate string to determine if they match as equal.
-
-
-
Method Detail
-
findAction
public static java.util.Optional<MenuOption> findAction(java.lang.String requested, java.lang.String[] available, java.util.function.IntFunction<MenuOption> factory)
Finds the first action inavailablematchingrequested, then maps its index throughfactoryto produce a MenuOption.- Parameters:
requested- The action string to match.available- The array of actions to match.factory- The factory to produce a MenuOption.- Returns:
- The first action in
availablematchingrequested,
-
matches
public static boolean matches(java.lang.String requested, java.lang.String candidate)Compares a requested string with a candidate string to determine if they match as equal.The comparison is case-insensitive and applies sanitation to the candidate string before performing the comparison.
- Parameters:
requested- The string to be matched against.candidate- The string to check, potentially unsanitized. Ifcandidateisnull, the method will returnfalse.- Returns:
trueif the sanitizedcandidatematchesrequested(case-insensitively); otherwise,false.
-
-