Java Utililty Methods Collection Add

List of utility methods to do Collection Add

Description

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

Method

voidaddConditionImpl(Collection conditions, String condition, String value)
add Condition Impl
conditions.add(condition + " " + value);
CollectionaddDirToStringPaths(Collection ss, String dir)
add Dir To String Paths
ArrayList<String> newss = new ArrayList<String>();
for (String s : ss) {
    try {
        s = addDirToStringPath(s, dir);
        if (s != null)
            newss.add(s);
    } catch (Exception e) {
        e.printStackTrace();
...
Listadded(Collection old, Collection nu)
added
List<String> added = null;
for (String s : nu) {
    if (!old.contains(s)) {
        if (added == null) {
            added = new ArrayList<String>(nu.size());
        added.add(s);
return added;
Collectionadded(Collection a, Collection b)
returns the elements added in List a with respect to b
Collection<T> aCopy = new ArrayList<T>(a);
Collection<T> bCopy = new ArrayList<T>(b);
aCopy.removeAll(bCopy);
return aCopy;
CollectionaddIf(Collection coll, T value, boolean expr)
Adds a value to the collection if the boolean expression is true.
if (expr)
    coll.add(value);
return coll;
booleanaddIfAbsent(Collection c, T item)
add If Absent
return !c.contains(item) && c.add(item);
voidaddIfMissing(Collection result, Iterable addition)
add If Missing
if (addition == null) {
    return;
for (E e : addition) {
    if (!result.contains(e)) {
        result.add(e);
booleanaddIfNotContains(Collection collection, T value)
add If Not Contains
if (collection != null && value != null && !collection.contains(value)) {
    return collection.add(value);
} else {
    return false;
voidaddIfNotEmpty(Collection c, Collection elements)
add If Not Empty
if (null != c && null != elements && !elements.isEmpty()) {
    c.addAll(elements);
voidaddIfNotNull(Collection c, Object element)
add If Not Null
if (element != null) {
    c.add(element);