Java Collection Add addIfAbsent(Collection c, T item)

Here you can find the source of addIfAbsent(Collection c, T item)

Description

add If Absent

License

Apache License

Declaration

public static <T> boolean addIfAbsent(Collection<? super T> c, T item) 

Method Source Code

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

import java.util.Collection;

public class Main {
    public static <T> boolean addIfAbsent(Collection<? super T> c, T item) {
        return !c.contains(item) && c.add(item);
    }//  w  ww .j  av  a  2 s . co m
}

Related

  1. addConditionImpl(Collection conditions, String condition, String value)
  2. addDirToStringPaths(Collection ss, String dir)
  3. added(Collection old, Collection nu)
  4. added(Collection a, Collection b)
  5. addIf(Collection coll, T value, boolean expr)
  6. addIfMissing(Collection result, Iterable addition)
  7. addIfNotContains(Collection collection, T value)
  8. addIfNotEmpty(Collection c, Collection elements)
  9. addIfNotNull(Collection c, Object element)