Interface ISearcher<TElement>

Type Parameters:
TElement - type of collection elements
All Known Subinterfaces:
IBorderedSearcher<TElement>
All Known Implementing Classes:
AttributesSearcher, BorderedSearcher, FormCommandSearcher, FormParameterSearcher, ItemsSearcher, NodeSearcher, Searcher

public interface ISearcher<TElement>
Represents a generic bidirectional ordered searcher with repositioning and narrowing search scope between two elements.
  • Method Details

    • init

      void init(List<TElement> containerToSearchIn)
      Initializes searcher by specified container to search in.
      Parameters:
      containerToSearchIn - the container to search in, cannot be null
    • setFilterData

      void setFilterData(FilterData filterData)
      Sets the filter data for searching.
      Parameters:
      filterData - the filter data for searching, cannot be null
    • getFilterData

      FilterData getFilterData()
      Gets current filter data.
      Returns:
      the current filter data, can be null
    • canSearch

      boolean canSearch()
      Gets a value indicating whether the searching can be executed.
      The searching can be executed if the filter was set from non-empty data; see setFilterData(FilterData).
      Returns:
      true if the searching can be executed, false otherwise
    • search

      TElement search()
      Searches forward.
      Returns:
      the found element, may be null if matching element not found
    • searchBack

      TElement searchBack()
      Searches backward.
      Returns:
      the found element, may be null if matching element not found
    • resetSearch

      void resetSearch()
      Resets search progress to start searching again.
    • repositionTo

      void repositionTo(TElement element)
      Repositions to specific element.
      Parameters:
      element - the element to which to reposition, cannot be null
      Throws:
      NoSuchElementException - when the requested element does not exist
    • repositionToNextElement

      TElement repositionToNextElement()
      Repositions to next element.
      Returns:
      next element, never null
      Throws:
      NoSuchElementException - when the canSearchNext() is false
    • repositionToPrevElement

      TElement repositionToPrevElement()
      Repositions to prev element.
      Returns:
      prev element, never null
      Throws:
      NoSuchElementException - when the canSearchPrev() is false
    • repositionToTheEnd

      void repositionToTheEnd()
      Starts searching from the end of data.
    • repositionToTheBeginning

      void repositionToTheBeginning()
      Starts searching from the beginning of data.
    • canSearchPrev

      boolean canSearchPrev()
      Checks if searcher not traversed to the beginning of the input and previous element is given.
      Returns:
      false current element is the first one in collection or reached beginning of data, true otherwise
    • canSearchNext

      boolean canSearchNext()
      Checks if searcher not traversed to the end of the input and next element is given.
      Returns:
      false current element is the last one in collection or reached end of data, true otherwise
    • canRepositionTo

      boolean canRepositionTo(TElement element)
      Checks if search can be repositioned to given element. Searcher can be repositioned to given element, if element is present in input.
      Parameters:
      element - the element to reposition searcher to, cannot be null
      Returns:
      true if repositioning is possible, false otherwise
    • getElementType

      default Class<TElement> getElementType()
      Provides search element type
      Returns:
      search element type, can be null if element type is not applicable/used