Class OptionSearchFilter

java.lang.Object
megamek.client.ui.panels.OptionSearchFilter

public final class OptionSearchFilter extends Object
The text matching behind the search boxes on the option lists (special pilot abilities, quirks).

Matching is a case-insensitive substring test. Callers normalize a row's searchable text once, when the row is built, and normalize the filter text once per filter pass, so a keystroke costs one String.contains(java.lang.CharSequence) per row rather than a fresh lower-casing of everything.

  • Method Details

    • normalize

      public static String normalize(String text)
      Parameters:
      text - any display text
      Returns:
      the text folded to a form suitable for matching. Always apply this to both sides before calling matches(String, String).
    • matches

      public static boolean matches(String normalizedSearchText, String normalizedFilter)
      Parameters:
      normalizedSearchText - a row's searchable text, already normalized
      normalizedFilter - the filter text, already normalized
      Returns:
      true if the row should stay visible: an empty filter matches everything, otherwise the search text must contain the filter