public static void addToListIfNotExists(List<String> list, String value) {
        boolean found = false;
        for (String item : list) {
            if (item.equalsIgnoreCase(value)) {
                found = true;
                break;
            }
        }
        if (!found) {
            list.add(value);
        }
    }
public static void addToListIfNotExists ( List < String > list , String value ) { boolean found = false ; for ( String item : list ) { if ( item . equalsIgnoreCase ( value ) ) { found = true ; break ; } } if ( ! found ) { list . add ( value ) ; } }
Adds a value to the list if does not already exists.

@param list the list
@param value value to add if not exists in the list