Class DataResult<T>

java.lang.Object
com.oorian.data.DataResult<T>
Type Parameters:
T - the item type

public class DataResult<T> extends Object
Contains the result of a DataProvider fetch operation.

Holds the fetched items and the total count of available items (for pagination). The total count represents all items matching the query's filters, not just the items in this page.

Since:
2.1
Version:
1.0
Author:
Marvin P. Warble Jr.
  • Constructor Details

    • DataResult

      public DataResult(List<T> items, int totalCount)
      Creates a data result.
      Parameters:
      items - the fetched items
      totalCount - the total number of items matching the query (for pagination)
  • Method Details

    • of

      public static <T> DataResult<T> of(List<T> items, int totalCount)
      Creates a data result from items and total count.
      Type Parameters:
      T - the item type
      Parameters:
      items - the fetched items
      totalCount - the total number of available items
      Returns:
      a new data result
    • empty

      public static <T> DataResult<T> empty()
      Creates an empty data result.
      Type Parameters:
      T - the item type
      Returns:
      an empty data result with zero total count
    • getItems

      public List<T> getItems()
      Returns the fetched items.
      Returns:
      unmodifiable list of items
    • getTotalCount

      public int getTotalCount()
      Returns the total count of items matching the query.
      Returns:
      the total item count
    • getSize

      public int getSize()
      Returns the number of items in this result page.
      Returns:
      the number of fetched items
    • isEmpty

      public boolean isEmpty()
      Returns whether this result contains any items.
      Returns:
      true if the result is empty