com.atlassian.jira.rest.api.expand
Class SimpleListWrapper<T>

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

public class SimpleListWrapper<T>
extends Object
implements com.atlassian.plugins.rest.common.expand.entity.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
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
static
<T> SimpleListWrapper<T>
empty()
          Returns an empty SimpleListWrapper.
 com.atlassian.plugins.rest.common.expand.entity.ListWrapperCallback<T> getCallback()
           
 int getMaxResults()
           
 com.atlassian.plugins.rest.common.expand.entity.ListWrapperCallback<T> getPagingCallback()
          Returns a ListWrapperCallback that the REST plugin can use to retrieve elements having specific indexes.
 int getSize()
           
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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

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.common.expand.entity.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 int getMaxResults()

getCallback

public final com.atlassian.plugins.rest.common.expand.entity.ListWrapperCallback<T> getCallback()
Specified by:
getCallback in interface com.atlassian.plugins.rest.common.expand.entity.ListWrapper<T>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2013 Atlassian. All Rights Reserved.