List of usage examples for java.util Collection contains
boolean contains(Object o);
From source file:Main.java
/** * Implementation of the OCL//from www .jav a2s .c o m * <tt>Collection::includes(object : T) : Boolean</tt> * operation. * * @param self the source collection * @param object an object * @return whether the collection includes the object */ public static boolean includes(Collection<?> self, Object object) { return self.contains(object); }
From source file:Main.java
public static boolean isSubsetOf(Collection<String> subset, Collection<String> superset) { for (String string : subset) { if (!superset.contains(string)) { return false; }/*from w w w . j av a 2s . co m*/ } return true; }
From source file:Main.java
public static <T> int countCommonElements(Collection<T> c1, Collection<T> c2) { int nbCommon = 0; for (T e : c1) { if (c2.contains(e)) { nbCommon++;//from www.java 2s . co m } } return nbCommon; }
From source file:Main.java
public static boolean intersects(final Collection<?> c1, final Collection<?> c2) { for (Object o : c1) { if (c2.contains(o)) return true; }//from w ww.j a va 2 s . c om return false; }
From source file:Main.java
public static void addAllWithoutDuplicates(Collection collection, Collection addTo) { for (Object obj : addTo) { if (!collection.contains(obj)) { collection.add(obj);//from w w w .ja v a 2 s . com } } }
From source file:Main.java
public static boolean contains(Object o, Collection<?> c) { if (c == null) { return false; }/* ww w. j a va2s . com*/ return c.contains(o); }
From source file:Main.java
public static boolean collectionContainsIgnoringCase(Collection<String> collection, String val) { if (collection.contains(val)) { return true; }// w w w .ja va 2 s.c o m for (String f : collection) { if (f == val) { return true; } if (f == null) { return false; } if (f.equalsIgnoreCase(val)) { return true; } } return false; }
From source file:Main.java
/** * Returns true if the given collection includes the given item. * * @param collection The collection to check item existence in. * @param item The item whose existence in the collection is to be checked. * @param <E> The component type of the collection. * @return True if the given collection contains the given item. *///from w w w . ja va 2s . co m public static <E> boolean includes(Collection<E> collection, E item) { return collection != null && collection.contains(item); }
From source file:Main.java
public static <T> boolean isNullOrContains(final Collection<?> collection, final T item) { return ((collection == null) || collection.contains(item)); }
From source file:Main.java
public static <T> boolean isNotNullAndContains(final Collection<?> collection, final T item) { return ((collection == null) && collection.contains(item)); }