Class SimpleListWrapper<T>

java.lang.Object
com.atlassian.jira.rest.api.expand.SimpleListWrapper<T>
All Implemented Interfaces:
com.atlassian.plugins.rest.api.expand.listwrapper.ListWrapper<T>

public class SimpleListWrapper<T> extends Object implements com.atlassian.plugins.rest.api.expand.listwrapper.ListWrapper<T>
This is a list wrapper that works by wrapping a java.util.Collection that has been eagerly loaded into memory. As such, it does not take full advantage of the "expandable" concepts since it requires callers to have previously loaded the entire data set into memory, but it has the advantage of being simple to implement.

This class makes a shallow copy of the wrapped collection.

Since:
v4.2
See Also:
  • Expandable
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SimpleListWrapper(List<T> list, Integer maxResults, int size)
    Creates a new SimpleListWrapper backed by the given list and returns at most maxResults items to the client.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> SimpleListWrapper<T>
    Returns an empty SimpleListWrapper.
    final com.atlassian.plugins.rest.api.expand.listwrapper.ListWrapperCallback<T>
     
     
    com.atlassian.plugins.rest.api.expand.listwrapper.ListWrapperCallback<T>
    Returns a ListWrapperCallback that the REST plugin can use to retrieve elements having specific indexes.
    int
     
    static <T> SimpleListWrapper<T>
    of(List<T> list)
    Returns a new SimpleListWrapper that is backed by the given collection.
    static <T> SimpleListWrapper<T>
    of(List<T> list, Integer maxResults)
    Returns a new SimpleListWrapper that is backed by the given list and returns at most maxResults items to the client.
    static <T> SimpleListWrapper<T>
    of(List<T> list, Integer maxResults, int size)
    Returns a new SimpleListWrapper that is backed by the given list and returns at most maxResults items to the client.
    static <T> SimpleListWrapper<T>
    of(T... elements)
    Returns a new SimpleListWrapper that wraps the given elements.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SimpleListWrapper

      protected SimpleListWrapper(List<T> list, Integer maxResults, int size)
      Creates a new SimpleListWrapper backed by the given list and returns at most maxResults items to the client.
      Parameters:
      list - a Collection
      maxResults - the maximum number of results to return to the client in one call
      size - the size of the data set
  • Method Details

    • empty

      public static <T> SimpleListWrapper<T> empty()
      Returns an empty SimpleListWrapper.
      Type Parameters:
      T - the type of the list element
      Returns:
      an empty SimpleListWrapper
    • of

      public static <T> SimpleListWrapper<T> of(T... elements)
      Returns a new SimpleListWrapper that wraps the given elements.
      Type Parameters:
      T - the type of the list element
      Parameters:
      elements - the elements to wrap
      Returns:
      a new SimpleListWrapper
    • of

      public static <T> SimpleListWrapper<T> of(List<T> list)
      Returns a new SimpleListWrapper that is backed by the given collection.
      Type Parameters:
      T - the type of the list element
      Parameters:
      list - the backing Collection
      Returns:
      a new SimpleListWrapper
    • of

      public static <T> SimpleListWrapper<T> of(List<T> list, Integer maxResults)
      Returns a new SimpleListWrapper that is backed by the given list and returns at most maxResults items to the client.
      Type Parameters:
      T - the type of the list element
      Parameters:
      list - the backing List
      maxResults - the maximum number of results to return to the client in one call, or null
      Returns:
      a new SimpleListWrapper
    • of

      public static <T> SimpleListWrapper<T> of(List<T> list, Integer maxResults, int size)
      Returns a new SimpleListWrapper that is backed by the given list and returns at most maxResults items to the client. The size attribute will contain the provided value, instead of the actual size of the passed-in list.
      Type Parameters:
      T - the type of the list element
      Parameters:
      list - the backing List
      maxResults - the maximum number of results to return to the client in one call
      size - the size of the data set
      Returns:
      a new SimpleListWrapper
    • getPagingCallback

      public com.atlassian.plugins.rest.api.expand.listwrapper.ListWrapperCallback<T> getPagingCallback()
      Returns a ListWrapperCallback that the REST plugin can use to retrieve elements having specific indexes.
      Returns:
      a ListWrapperCallback
    • getSize

      public int getSize()
    • getMaxResults

      public Integer getMaxResults()
    • getCallback

      public final com.atlassian.plugins.rest.api.expand.listwrapper.ListWrapperCallback<T> getCallback()
      Specified by:
      getCallback in interface com.atlassian.plugins.rest.api.expand.listwrapper.ListWrapper<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object