Class ObjectPaginator

java.lang.Object
org.apache.juneau.objecttools.ObjectPaginator
All Implemented Interfaces:
ObjectTool<PageArgs>

public final class ObjectPaginator extends Object implements ObjectTool<PageArgs>
POJO model paginator.

This class is designed to extract sublists from arrays/collections of maps or beans.

Example:

MyBean[] arrayOfBeans = ...; ObjectPaginator paginator = ObjectPaginator.create(); // Returns all rows from 100 to 110. List<MyBean> result = paginator.run(arrayOfBeans, 100, 10);

The tool can be used against the following data types:

  • Arrays/collections of maps or beans.
See Also:
  • Constructor Details

  • Method Details

    • create

      public static ObjectPaginator create()
      Static creator.
      Returns:
      A new ObjectPaginator object.
    • run

      public <R> List<R> run(Object input, int pos, int limit)
      Convenience method for executing the paginator.
      Type Parameters:
      R - The collection element type.
      Parameters:
      input - The input. Must be a collection or array of objects.
      pos - The zero-index position to start from.
      limit - The max number of entries to retrieve.
      Returns:
      A sublist of representing the entries from the position with the specified limit.
    • run

      public Object run(BeanSession session, Object input, PageArgs args)
      Description copied from interface: ObjectTool
      Converts the specified input to some other output.
      Specified by:
      run in interface ObjectTool<PageArgs>
      Parameters:
      session - The current bean session.
      input - The input POJO.
      args - The arguments.
      Returns:
      The output POJO.