Class BasicFilterResults<M extends Identity<K>,K>

java.lang.Object
net.solarnetwork.dao.BasicFilterResults<M,K>
All Implemented Interfaces:
Iterable<M>, FilterResults<M,K>

public class BasicFilterResults<M extends Identity<K>,K> extends Object implements FilterResults<M,K>
Basic implementation of FilterResults.
Since:
1.59
Version:
1.2
Author:
matt
  • Constructor Details

    • BasicFilterResults

      public BasicFilterResults(Iterable<M> results, Long totalResults, int startingOffset, int returnedResultCount)
      Constructor.
      Parameters:
      results - the results iterable
      totalResults - the total available results, or null
      startingOffset - the starting offset
      returnedResultCount - the count of objects in results
    • BasicFilterResults

      public BasicFilterResults(Iterable<M> results)
      Constructor.

      This total results count will be set to null, the starting offset to 0, and the returned result count will be derived from the number of items in results.

      Parameters:
      results - the results iterable
  • Method Details

    • filterResults

      public static <M extends Identity<K>, K> FilterResults<M,K> filterResults(Iterable<M> data, PaginationCriteria criteria, Long totalResults, int returnedResults)
      Create a FilterResults instance.
      Type Parameters:
      M - the result type
      K - the result key type
      Parameters:
      data - the result data
      criteria - the criteria used to produce the results
      totalResults - the total result count, if available
      returnedResults - the returned results count
      Returns:
      the results instance
      Since:
      1.1
    • iterator

      public Iterator<M> iterator()
      Specified by:
      iterator in interface Iterable<M extends Identity<K>>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getResults

      public Iterable<M> getResults()
      Description copied from interface: FilterResults
      Get the actual results.

      These are the same results returned by Iterable.iterator().

      Specified by:
      getResults in interface FilterResults<M extends Identity<K>,K>
      Returns:
      the results, never null
    • getTotalResults

      public Long getTotalResults()
      Description copied from interface: FilterResults
      Get a total number of available results, if known.

      If this result represents partial results and the total count of available results is known, this value represents that total count of available results.

      Specified by:
      getTotalResults in interface FilterResults<M extends Identity<K>,K>
      Returns:
      total available results, or null if not known
    • getStartingOffset

      public int getStartingOffset()
      Description copied from interface: FilterResults
      Get the starting offset of the returned results.
      Specified by:
      getStartingOffset in interface FilterResults<M extends Identity<K>,K>
      Returns:
      the starting offset
    • getReturnedResultCount

      public int getReturnedResultCount()
      Description copied from interface: FilterResults
      Get the number of results that matched the query.
      Specified by:
      getReturnedResultCount in interface FilterResults<M extends Identity<K>,K>
      Returns:
      the number of returned results