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

voidadd(final Integer id, final TreeMap> map, T object)
add
List<T> list = map.get(id);
if (list == null) {
    list = new ArrayList<>();
    map.put(id, list);
list.add(object);
Listadd(final List list, final T... objects)
add
if (objects == null)
    return list;
for (final T object : objects)
    list.add(object);
return list;
voidadd(final List toList, final List fromList)
add
if (toList == null || fromList == null) {
    return;
for (T t : fromList) {
    if (!toList.contains(t)) {
        toList.add(t);
voidadd(List list, int index, Object element)
Adds a object to a list and extends the list by null values if the index is greater than the size.
int size = list.size();
if (index < size) {
    list.add(index, element);
    return;
for (int i = size; i < index; i++) {
    list.add(null);
list.add(element);
Listadd(List valList, Object src)
add
if (src == null) {
    return valList;
if (src instanceof List) {
    valList.addAll((List) src);
} else {
    valList.add(src);
return valList;
Listadd(List list, E element)
Returns the given List instance or a new List instance if the given one is null.
@SuppressWarnings("unchecked")
List<E> retlist = (List<E>) list;
if (list == null) {
    retlist = new ArrayList<E>();
retlist.add(element);
return retlist;
voidadd(List result, ClassLoader loader)
add
if (loader != null) {
    result.add(loader);
Listadd(List list, E element)
add
if (element != null) {
    List<E> newList = new ArrayList<E>();
    if (list != null) {
        newList.addAll(list);
    newList.add(element);
    return newList;
return list;
voidadd(List list, int index, T item)
Adds the given item to the list at specified index.
if (index < list.size())
    list.add(index, item);
else
    list.add(item);
voidadd(List list, int index, T item)
Adds the given item to the list at specified index.
if (index < list.size()) {
    list.add(index, item);
} else {
    list.add(item);