Class Search<E extends Locatable>

java.lang.Object
org.cruk.clarity.api.search.Search<E>
Type Parameters:
E - The type of object the search is for.
All Implemented Interfaces:
Serializable

public class Search<E extends Locatable> extends Object implements Serializable
A class holding both the parameters of a search and the links returned from that search.
See Also:
  • Field Details

  • Constructor Details

    • Search

      public Search(Map<String,?> searchTerms, Class<E> entityClass)
      Constructor that takes the parameters from a call to the API's find method.
      Parameters:
      searchTerms - The search parameters.
      entityClass - The type of object being searched for.
    • Search

      public Search(SearchTerms<E> searchTerms)
      Constructor that accepts an already created SearchTerms object.
      Parameters:
      searchTerms - The search terms.
      Throws:
      IllegalArgumentException - if searchTerms is null.
  • Method Details

    • getSearchTerms

      public SearchTerms<E> getSearchTerms()
      Get the parameters of this search.
      Returns:
      The search terms.
    • getResults

      public List<LimsLink<E>> getResults()
      Get the results of the search.
      Returns:
      A list of links to the entities searched for.
    • setResults

      public void setResults(List<LimsLink<E>> results)
      Set the results of the search.
      Parameters:
      results - The links that are the result of the search.
    • merge

      public boolean merge(Search<E> otherSearch)
      Merge the results of another search into this search's results.
      Parameters:
      otherSearch - The search to merge in. Must be a search for the same type of entities as this search.
      Returns:
      true if any results have been added to this search's results from the other search, false if not (i.e. if this search's results have not changed).
      Throws:
      IllegalArgumentException - if otherSearch is a search for a different type of entity.
    • toString

      public String toString()
      Get a human readable representation of this object. Shows the search terms and, if results are set, the number of links in the results.
      Overrides:
      toString in class Object
      Returns:
      A printable representation of this object.
    • getSearchFileName

      public String getSearchFileName()
      Get the name of the file that will store the result of this search.
      Returns:
      The name of the file the search will be stored in.
    • getSearchFileName

      public static String getSearchFileName(SearchTerms<?> terms)
      Get the name of the file that will store the result of the given search. Convenience method here meaning all calls for record and playback will be consistent.
      Parameters:
      terms - The search terms.
      Returns:
      The name of the file the search will be stored in.