Interface SearchFilter

All Superinterfaces:
BiPredicate<MenuItem,String>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SearchFilter extends BiPredicate<MenuItem,String>
Represents a filter for matching menu items against a search query. Used by typeahead components and MenuSearch to determine which items are visible for a given input value.
See Also:
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    Creates a filter that matches menu items whose text contains the search query (case-insensitive).
    containsAll(char delimiter)
    Creates a filter that splits the search query by the given delimiter, then checks that the menu item's text contains all non-empty terms (case-insensitive).
    lastSegment(char delimiter)
    Creates a filter that uses only the text after the last occurrence of the given delimiter for matching.

    Methods inherited from interface BiPredicate

    and, negate, or, test
  • Method Details

    • contains

      static SearchFilter contains()
      Creates a filter that matches menu items whose text contains the search query (case-insensitive).
      Returns:
      a SearchFilter that evaluates to true if the menu item's text contains the search text (case-insensitive).
    • containsAll

      static SearchFilter containsAll(char delimiter)
      Creates a filter that splits the search query by the given delimiter, then checks that the menu item's text contains all non-empty terms (case-insensitive). For example, with delimiter '/', the query "tolkien/rings" matches any item whose text contains both "tolkien" and "rings".
      Parameters:
      delimiter - the character used to split the query into terms
      Returns:
      a SearchFilter that matches items containing all query terms
    • lastSegment

      static SearchFilter lastSegment(char delimiter)
      Creates a filter that uses only the text after the last occurrence of the given delimiter for matching. If the delimiter is not present, the entire query is used. Matching is case-insensitive.

      This is useful for hierarchical typeaheads where the text before the delimiter selects a category, and the text after it filters within that category. For example, with delimiter '/', the query "laptops/mac" filters items using only "mac".

      Parameters:
      delimiter - the character that separates hierarchical segments
      Returns:
      a SearchFilter that matches items against the last segment of the query