Class PageImpl<T>

java.lang.Object
com.atlassian.bitbucket.util.PageImpl<T>
All Implemented Interfaces:
Page<T>

public class PageImpl<T> extends Object implements Page<T>
  • Constructor Details

    • PageImpl

      public PageImpl(PageRequest pageRequest, int size, Iterable<T> values, boolean lastPage)
      Creates a page from the provided values and explicitly sets getIsLastPage() and size. The next PageRequest will be inferred from the start and limit of the provided PageRequest.
      Parameters:
      pageRequest - the page request used to create this page
      size - the size of the page - i.e. the number of elements in this page
      values - an iterable of the values
      lastPage - if this is the last page
    • PageImpl

      public PageImpl(PageRequest pageRequest, Iterable<T> values, boolean lastPage, int size, int nextPageStart)
      Creates a page from the provided values and explicitly sets getIsLastPage() and size. The next PageRequest will start from the specified nextPageStart, with the same limit as the provided PageRequest.
      Parameters:
      pageRequest - the page request used to create this page
      values - an iterable of the values
      lastPage - if this is the last page
      size - the size of the page - i.e. the number of elements in this page
      nextPageStart - index of the element that will be the first in the next page
      Since:
      4.12
    • PageImpl

      public PageImpl(PageRequest pageRequest, Iterable<T> values, boolean lastPage)
      Creates a page from the provided values and explicitly sets getIsLastPage().
      Parameters:
      pageRequest - the page request used to create this page
      values - an iterable of the values
      lastPage - if this is the last page
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • forEach

      public void forEach(@Nonnull Consumer<? super T> action)
      Description copied from interface: Page
      Performs an action on each result in the page.
      Specified by:
      forEach in interface Page<T>
      Parameters:
      action - the action to apply to each result
      Since:
      6.3
    • getIsLastPage

      public boolean getIsLastPage()
      Specified by:
      getIsLastPage in interface Page<T>
      Returns:
      true if there are no more results; otherwise, false if at least one more page, perhaps partially filled but not empty, of results is available
    • getLimit

      public int getLimit()
      Specified by:
      getLimit in interface Page<T>
      Returns:
      the original limit on the PageRequest that generated this page
    • getNextPageRequest

      public PageRequest getNextPageRequest()
      Specified by:
      getNextPageRequest in interface Page<T>
      Returns:
      a request which can be used to retrieve the next page, which will be null if this was the last page
    • getOrdinalIndexedValues

      @Nonnull public SortedMap<Integer,T> getOrdinalIndexedValues()
      Description copied from interface: Page
      Get a map of the page values mapped by their ordinal values. For filtered pages, the ordinals are the ordinals in the underlying paged collection.
      Specified by:
      getOrdinalIndexedValues in interface Page<T>
      Returns:
      values mapped by their ordinal value in the page
    • getSize

      public int getSize()
      Specified by:
      getSize in interface Page<T>
      Returns:
      the number of results in the page
    • getStart

      public int getStart()
      Specified by:
      getStart in interface Page<T>
      Returns:
      the offset into the overall result set the page starts at (0 based)
    • getValues

      @Nonnull public Iterable<T> getValues()
      Specified by:
      getValues in interface Page<T>
      Returns:
      the page's results
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • transform

      @Nonnull public <E> PageImpl<E> transform(@Nonnull Function<? super T,? extends E> transformFunction)
      Description copied from interface: Page
      Transforms the results on the page, producing a new Page with different values but all other properties (e.g. start and limit) unchanged.

      Implementation note: Transformation is done eagerly to ensure the resulting Page does not retain a reference to the original results from the source page. If a transform is used purely to apply some set of side effects, consider using Page.forEach(java.util.function.Consumer<? super T>) instead.

      Specified by:
      transform in interface Page<T>
      Type Parameters:
      E - the target type
      Parameters:
      transformFunction - the transformer
      Returns:
      a new page with transformed results
    • getNextPageOffset

      protected int getNextPageOffset()