Java Utililty Methods List Value Add

List of utility methods to do List Value Add

Description

The list of methods to do List Value Add are organized into topic(s).

Method

Listadd(List list, T element)
add
final ArrayList<T> result = new ArrayList<T>(list.size() + 2);
result.addAll(list);
result.add(element);
return result;
voidadd(Map> multiValueMap, String key, Object value)
add
put(multiValueMap, key, value, false);
Listadd(Object o, List oldList)
add
List newList;
if (oldList == null) {
    newList = new ArrayList(1);
} else {
    newList = new ArrayList(oldList.size() + 1); 
    newList.addAll(oldList);
newList.add(o);
...
ListaddElement(T element, List list)
add Element
boolean exists = false;
if (list == null) {
    list = new ArrayList<T>(2);
} else {
    exists = list.contains(element);
if (!exists)
    list.add(element);
...
voidaddElementIfAbsent(List l, T element)
Adds element as the last element of the List, if not already present within the List.
if (!l.contains(element)) {
    l.add(element);
voidaddElements(boolean removeDuplicates, final List result, Collection elements)
add Elements
for (E item : elements) {
    if (removeDuplicates) {
        if (!result.contains(item)) {
            result.add(item);
    } else {
        result.add(item);
booleanaddElements(List list, T[] array)
add Elements
boolean good = true;
for (T obj : array) {
    good &= list.add(obj);
return good;
voidaddElementsIfAbsent(List destList, Collection aColl)
Adds the elements contained in aList that are not already present in the List to the end of the List.
if (aColl == null) {
    return;
Iterator<? extends T> i = aColl.iterator();
while (i.hasNext()) {
    addElementIfAbsent(destList, i.next());
ListappendToList(List list, A elem)
Return a new list with element appended to previous list.
List<A> answer = new ArrayList<A>(list);
answer.add(elem);
return answer;
ListappendToList(List list, T[] elements)
append To List
List<T> result = new ArrayList<T>(list.size() + elements.length);
result.addAll(list);
result.addAll(Arrays.asList(elements));
return result;