public class CollectionUtil extends Object
| Constructor and Description |
|---|
CollectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <A,E extends Collection<A>> |
addAll(E col,
A... e)
Ajoute a la collection tous les elements passés en parametre
|
static <A,E extends List<A>> |
addAll(E col,
int pos,
A... e)
Ajoute a la liste tous les elements passés en parametre
|
static <T> T |
get(Collection<T> collection,
int index)
Get data at given
index from the given collection. |
static <T> T |
get(List<T> list,
int index)
Get data at given
index from the given list. |
static <T> T |
getOrNull(Collection<T> collection,
int index)
Get data at given
index from the given collection or
null if no element at given position. |
static <T> T |
getOrNull(List<T> list,
int index)
Get data at given
index from the given list or null if
no such index in list. |
static <O> Collection<O> |
toGenericCollection(Collection<?> list,
Class<O> type)
Permet de convertir une collection non typée, en une collection typée.
|
static <O> List<O> |
toGenericList(List<?> list,
Class<O> type)
Permet de convertir une liste non typée, en une liste typée.
|
static <O> Set<O> |
toGenericSet(Set<?> list,
Class<O> type)
Permet de convertir un ensemble non typée, en un ensemble typée.
|
public static <A,E extends Collection<A>> E addAll(E col, A... e)
A - FIXMEE - FIXMEcol - la collectione - les elements a ajouterpublic static <A,E extends List<A>> E addAll(E col, int pos, A... e)
A - FIXMEE - FIXMEcol - la listepos - le premier index où insérer les donnéese - les elements a ajouterpublic static <O> List<O> toGenericList(List<?> list, Class<O> type) throws IllegalArgumentException
La liste en entrée en juste bien castée.
On effectue une vérification sur le typage des élements de la liste.
Note : Aucune liste n'est créee, ni recopiée
O - data typelist - la liste à convertirtype - le type des éléments de la listeIllegalArgumentException - si un élément de la liste en entrée n'est
pas en adéquation avec le type voulue.public static <O> Collection<O> toGenericCollection(Collection<?> list, Class<O> type) throws IllegalArgumentException
La collection en entrée en juste bien castée.
On effectue une vérification sur le typage des élements de la collection.
Note : Aucune collection n'est créee, ni recopiée
O - data typelist - la collection à convertirtype - le type des éléments de la collectionIllegalArgumentException - si un élément de la collection en entrée n'est
pas en adéquation avec le type voulue.public static <O> Set<O> toGenericSet(Set<?> list, Class<O> type) throws IllegalArgumentException
L'ensemble en entrée en juste bien castée.
On effectue une vérification sur le typage des élements de la collection.
Note : Aucun ensemble n'est créee, ni recopiée
O - data typelist - l'ensemble à convertirtype - le type des éléments de l'ensembleIllegalArgumentException - si un élément de l'ensemble en entrée n'est
pas en adéquation avec le type voulue.public static <T> T getOrNull(Collection<T> collection, int index)
index from the given collection or
null if no element at given position.T - type of data in collectioncollection - the collection to scanindex - index to seeknull if not foundpublic static <T> T get(Collection<T> collection, int index) throws IndexOutOfBoundsException
index from the given collection.T - type of data in collectioncollection - the collection to scanindex - index to seekIndexOutOfBoundsException - if there is such index in collectionpublic static <T> T get(List<T> list, int index) throws IndexOutOfBoundsException
index from the given list.T - type of data in collectionlist - the list to scanindex - index to seekIndexOutOfBoundsException - if there is such index in listpublic static <T> T getOrNull(List<T> list, int index)
index from the given list or null if
no such index in list.T - type of data in collectionlist - the list to scanindex - index to seeknull if no such index in listCopyright © 2004–2020 CodeLutin. All rights reserved.