Package org.silverpeas.core.util
Interface SilverpeasList<T>
-
- All Superinterfaces:
Collection<T>
,Iterable<T>
,List<T>
- All Known Implementing Classes:
ListSlice
,PaginationList
,SilverpeasArrayList
,SilverpeasListWrapper
public interface SilverpeasList<T> extends List<T>
A common definition of Silverpeas's list in order to get common behaviours.- Author:
- Yohann Chastagnier
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <T> SilverpeasList<T>
as(T[] arrayToConvert)
Gets an array as aSilverpeasList
.static <C,R extends SilverpeasList<C>>
Collector<C,R,R>collector(List<?> source)
Returns aCollector
that accumulates the input items into a newSilverpeasList
.default boolean
isSlice()
Indicates if the list is a slice of a larger one.<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.static <T> SilverpeasList<T>
wrap(List<T> listToWrap)
Gets a wrapper of any kind of implementation ofList
in order to get aSilverpeasList
behaviour.-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
-
-
-
Method Detail
-
collector
static <C,R extends SilverpeasList<C>> Collector<C,R,R> collector(List<?> source)
Returns aCollector
that accumulates the input items into a newSilverpeasList
. There are no guarantees on the type, mutability, serializability, or thread-safety of the returnedSilverpeasList
.If the source is already a
SilverpeasList
, then the returned list will be of the same concrete type than the source list.- Type Parameters:
C
- the type of the input items in the destination list.R
- the concrete type of theSilverpeasList
.- Parameters:
source
- the source list from which a SilverpeasList is built.- Returns:
- a
Collector
which collects all the input elements into aSilverpeasList
, in encounter order.
-
as
static <T> SilverpeasList<T> as(T[] arrayToConvert)
Gets an array as aSilverpeasList
.- Type Parameters:
T
- the type of the elements into the array.- Parameters:
arrayToConvert
- the array to get asSilverpeasList
.- Returns:
- the
SilverpeasList
instance.
-
wrap
static <T> SilverpeasList<T> wrap(List<T> listToWrap)
Gets a wrapper of any kind of implementation ofList
in order to get aSilverpeasList
behaviour.If the given list is already a
SilverpeasList
one, no wrap is done and the given instance is returned immediately.- Type Parameters:
T
- the type of the elements into the list.- Parameters:
listToWrap
- the list to wrap.- Returns:
- the
SilverpeasList
instance.
-
newEmptyListWithSameProperties
<U> SilverpeasList<U> newEmptyListWithSameProperties()
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.
- 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
long originalListSize()
Gets the number of items the original list contains.If the list is a slice of a larger one, the
originalListSize()
returns a higher result than the one ofList.size()
, otherwiseoriginalListSize()
andList.size()
returns the same result.- Returns:
- the original size of the list as long.
-
isSlice
default boolean isSlice()
Indicates if the list is a slice of a larger one.- Returns:
- true if it represents a slice, false otherwise.
-
-