Class ActionResolver


  • public final class ActionResolver
    extends java.lang.Object
    Stateless 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 in available matching requested, then maps its index through factory to produce a MenuOption.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ActionResolver

        public ActionResolver()
    • 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 in available matching requested, then maps its index through factory to 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 available matching requested,
      • 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. If candidate is null, the method will return false.
        Returns:
        true if the sanitized candidate matches requested (case-insensitively); otherwise, false.