Class Searcher<TElement,C extends ICursor<TElement>>

java.lang.Object
com._1c.g5.v8.dt.common.search.Searcher<TElement,C>
Type Parameters:
TElement - type of collection elements
All Implemented Interfaces:
ISearcher<TElement>
Direct Known Subclasses:
AttributesSearcher, BorderedSearcher, FormCommandSearcher, FormParameterSearcher, ItemsSearcher

public abstract class Searcher<TElement,C extends ICursor<TElement>> extends Object implements ISearcher<TElement>
Represents an abstract generic two-directional searcher of elements with minimum required logic.
  • Field Details

    • cursor

      protected volatile C extends ICursor<TElement> cursor
      Cursor to traverse input collection.
    • filter

      protected Predicate<TElement> filter
      Predicate function for testing elements.
    • filterData

      protected FilterData filterData
      Data which element must match to.
  • Constructor Details

    • Searcher

      public Searcher()
  • Method Details

    • init

      public void init(List<TElement> containerToSearchIn)
      Description copied from interface: ISearcher
      Initializes searcher by specified container to search in.
      Specified by:
      init in interface ISearcher<TElement>
      Parameters:
      containerToSearchIn - the container to search in, cannot be null
    • getFilterData

      public FilterData getFilterData()
      Description copied from interface: ISearcher
      Gets current filter data.
      Specified by:
      getFilterData in interface ISearcher<TElement>
      Returns:
      the current filter data, can be null
    • setFilterData

      public void setFilterData(FilterData filterData)
      Description copied from interface: ISearcher
      Sets the filter data for searching.
      Specified by:
      setFilterData in interface ISearcher<TElement>
      Parameters:
      filterData - the filter data for searching, cannot be null
    • canSearch

      public boolean canSearch()
      Description copied from interface: ISearcher
      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 ISearcher.setFilterData(FilterData).
      Specified by:
      canSearch in interface ISearcher<TElement>
      Returns:
      true if the searching can be executed, false otherwise
    • search

      public TElement search()
      Description copied from interface: ISearcher
      Searches forward.
      Specified by:
      search in interface ISearcher<TElement>
      Returns:
      the found element, may be null if matching element not found
    • searchBack

      public TElement searchBack()
      Description copied from interface: ISearcher
      Searches backward.
      Specified by:
      searchBack in interface ISearcher<TElement>
      Returns:
      the found element, may be null if matching element not found
    • repositionToTheBeginning

      public void repositionToTheBeginning()
      Description copied from interface: ISearcher
      Starts searching from the beginning of data.
      Specified by:
      repositionToTheBeginning in interface ISearcher<TElement>
    • repositionTo

      public void repositionTo(TElement element)
      Description copied from interface: ISearcher
      Repositions to specific element.
      Specified by:
      repositionTo in interface ISearcher<TElement>
      Parameters:
      element - the element to which to reposition, cannot be null
    • resetSearch

      public void resetSearch()
      Description copied from interface: ISearcher
      Resets search progress to start searching again.
      Specified by:
      resetSearch in interface ISearcher<TElement>
    • repositionToNextElement

      public TElement repositionToNextElement()
      Description copied from interface: ISearcher
      Repositions to next element.
      Specified by:
      repositionToNextElement in interface ISearcher<TElement>
      Returns:
      next element, never null
    • repositionToPrevElement

      public TElement repositionToPrevElement()
      Description copied from interface: ISearcher
      Repositions to prev element.
      Specified by:
      repositionToPrevElement in interface ISearcher<TElement>
      Returns:
      prev element, never null
    • repositionToTheEnd

      public void repositionToTheEnd()
      Description copied from interface: ISearcher
      Starts searching from the end of data.
      Specified by:
      repositionToTheEnd in interface ISearcher<TElement>
    • canSearchPrev

      public boolean canSearchPrev()
      Description copied from interface: ISearcher
      Checks if searcher not traversed to the beginning of the input and previous element is given.
      Specified by:
      canSearchPrev in interface ISearcher<TElement>
      Returns:
      false current element is the first one in collection or reached beginning of data, true otherwise
    • canSearchNext

      public boolean canSearchNext()
      Description copied from interface: ISearcher
      Checks if searcher not traversed to the end of the input and next element is given.
      Specified by:
      canSearchNext in interface ISearcher<TElement>
      Returns:
      false current element is the last one in collection or reached end of data, true otherwise
    • canRepositionTo

      public boolean canRepositionTo(TElement element)
      Description copied from interface: ISearcher
      Checks if search can be repositioned to given element. Searcher can be repositioned to given element, if element is present in input.
      Specified by:
      canRepositionTo in interface ISearcher<TElement>
      Parameters:
      element - the element to reposition searcher to, cannot be null
      Returns:
      true if repositioning is possible, false otherwise
    • getCursor

      protected abstract C getCursor(List<TElement> input)
      Gets cursor to navigate via the specified elements. Override this method to provide concrete cursor.
      Parameters:
      input - the list of element to search in.
      Returns:
      the navigation cursor as ICursor.
    • getFilter

      protected abstract Predicate<TElement> getFilter(FilterData filterData)
      Gets searching filter. Override this method to provide concrete filter.
      Parameters:
      filterData - the filter data for searcher, can not be null.
      Returns:
      the filter as Predicate.
    • getFilterToPreservePositionOf

      protected Predicate<TElement> getFilterToPreservePositionOf(TElement oldElement)
      Executes on preserving the element position when initialization running init(List).
      Parameters:
      oldElement - the old element which position need to preserve in new cursor, can not be null.
      Returns:
      the predicate for ability to preserve the old element position when initialization running. If null then preserving will not happened.