Java Collection Add addNotNull(Collection col, String toAdd)

Here you can find the source of addNotNull(Collection col, String toAdd)

Description

add Not Null

License

LGPL

Declaration

public static void addNotNull(Collection<String> col, String toAdd) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Collection;

public class Main {
    public static void addNotNull(Collection<String> col, String toAdd) {
        //    if (toAdd != null && toAdd.length() > 0 && !col.contains("'" + toAdd.trim() + "'")) {
        //      col.add("'" + toAdd.trim() + "'");
        //    }/* w  w w.  j a  v a  2 s . co  m*/

        if (toAdd != null && toAdd.length() > 0 && !col.contains(toAdd.trim())) {
            col.add(toAdd.trim());
        }
    }
}

Related

  1. addMatchingStrings(Collection availableProperties, String startWith, Collection strings)
  2. addNewLines(Collection strings)
  3. addNonNull(Object element, Collection result)
  4. addNonnullIfMissing(Collection collection, T element)
  5. addNonNulls(Collection c, X... xl)
  6. addOneValueUNSAFE(Collection cloneCollection, Object v)
  7. addPrefix(Collection values, String prefix)
  8. addPreviousTags(int index, String[] prevTags, int prevTagsToAdd, Collection targetCol)
  9. addRange(Collection c, int start, int to, int step)