public class ListUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
addIfEquals(List<T> list,
T element1,
T element2)
Add element1 to the list only if it is equals to element2
|
static <T,T1> List<T> |
addIfEquals(List<T> list,
T elemToAdd,
T1 element1,
T1 element2)
Add elemToAdd to the list only if element1 is equals to element2
|
static <T> List<T> |
addIfNotContained(List<T> list,
T... elements)
add elements if not already contained
|
static <T> List<T> |
appendElementsToList(List<T> list,
T... elements)
Append elements to a list
|
static <T> List<T> |
createIfNull(List<T> list)
Create an ArrayList if the List is null;
|
static <T> List<T> |
prependElementsToList(List<T> list,
T... elements)
Prepend elements to a list
|
public static <T> List<T> appendElementsToList(List<T> list, T... elements)
T - The list and elements typelist - The listelements - The elements to appendpublic static <T> List<T> prependElementsToList(List<T> list, T... elements)
T - The list and elements typelist - The listelements - The elements to prependpublic static <T> List<T> addIfNotContained(List<T> list, T... elements)
T - The list and elements typelist - The listelements - The elements to addpublic static <T> List<T> addIfEquals(List<T> list, T element1, T element2)
T - The list and elements typelist - The listelement1 - The first elementelement2 - The second elementpublic static <T,T1> List<T> addIfEquals(List<T> list, T elemToAdd, T1 element1, T1 element2)
T - The list and elements typeT1 - The type of elements to checklist - The listelemToAdd - The element to addelement1 - The first elementelement2 - The second elementCopyright © 2018 Okkam srl. All rights reserved.