Package org.silverpeas.core.util
Class PaginationList<T>
- java.lang.Object
-
- org.silverpeas.core.util.SilverpeasListWrapper<T>
-
- org.silverpeas.core.util.PaginationList<T>
-
- Type Parameters:
T
- the type of the items in the list.
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,List<T>
,SilverpeasList<T>
public class PaginationList<T> extends SilverpeasListWrapper<T>
The pagination list is a decorator of a collection by adding it some methods used in the pagination. The pagination list defines a given page to a full collection of items.- Author:
- mmoquillon
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, T element)
boolean
add(T e)
boolean
addAll(int index, Collection<? extends T> c)
boolean
addAll(Collection<? extends T> c)
static <T> PaginationList<T>
from(Collection<T> aCollection)
Decorates the specified collection with pagination features.static <T> PaginationList<T>
from(Collection<T> aCollection, long maxItems)
Decorates the specified collection with pagination features.ListIterator<T>
listIterator()
ListIterator<T>
listIterator(int index)
<U> SilverpeasList<U>
newEmptyListWithSameProperties()
Builds a new emptySilverpeasList
with the same properties than this list.long
originalListSize()
Gets the number of items the original list contains.-
Methods inherited from class org.silverpeas.core.util.SilverpeasListWrapper
clear, contains, containsAll, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface org.silverpeas.core.util.SilverpeasList
isSlice
-
-
-
-
Method Detail
-
from
public static <T> PaginationList<T> from(Collection<T> aCollection)
Decorates the specified collection with pagination features. The resulting PaginationList instance defines a pagination of a single page containing the whole items of the specified collection; the size of the pagination is the size of the collection.- Type Parameters:
T
- the type of the items in the collection.- Parameters:
aCollection
- the collection to decorate.- Returns:
- a
PaginationList
instance.
-
from
public static <T> PaginationList<T> from(Collection<T> aCollection, long maxItems)
Decorates the specified collection with pagination features. The resulting PaginationList instance defines one page of a pagination and this page contains the whole items of the specified collections. The page is at the size of the decorated collection but the size of the pagination is greater.- Type Parameters:
T
- the type of the items in the collection.- Parameters:
aCollection
- the collection to decorate.maxItems
- the maximum number of items; that is the size of the pagination.- Returns:
- a
PaginationList
instance.
-
newEmptyListWithSameProperties
public <U> SilverpeasList<U> newEmptyListWithSameProperties()
Description copied from interface:SilverpeasList
Builds a new emptySilverpeasList
with the same properties than this list.This method is mainly dedicated to be used for making a collector for the Java Stream API.
- Specified by:
newEmptyListWithSameProperties
in interfaceSilverpeasList<T>
- Overrides:
newEmptyListWithSameProperties
in classSilverpeasListWrapper<T>
- Type Parameters:
U
- the concrete type of the items of the returned list.- Returns:
- an empty
SilverpeasList
with the same properties than this list.
-
originalListSize
public long originalListSize()
Description copied from interface:SilverpeasList
Gets the number of items the original list contains.If the list is a slice of a larger one, the
SilverpeasList.originalListSize()
returns a higher result than the one ofList.size()
, otherwiseSilverpeasList.originalListSize()
andList.size()
returns the same result.- Specified by:
originalListSize
in interfaceSilverpeasList<T>
- Overrides:
originalListSize
in classSilverpeasListWrapper<T>
- Returns:
- the original size of the list as long.
-
add
public boolean add(T e)
- Specified by:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceList<T>
- Overrides:
add
in classSilverpeasListWrapper<T>
-
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAll
in interfaceCollection<T>
- Specified by:
addAll
in interfaceList<T>
- Overrides:
addAll
in classSilverpeasListWrapper<T>
-
addAll
public boolean addAll(int index, Collection<? extends T> c)
-
add
public void add(int index, T element)
-
listIterator
public ListIterator<T> listIterator()
- Specified by:
listIterator
in interfaceList<T>
- Overrides:
listIterator
in classSilverpeasListWrapper<T>
-
listIterator
public ListIterator<T> listIterator(int index)
- Specified by:
listIterator
in interfaceList<T>
- Overrides:
listIterator
in classSilverpeasListWrapper<T>
-
-