List of usage examples for java.util Collection contains
boolean contains(Object o);
From source file:Main.java
private static void extractRemovedEntries(final Collection<String> oldCollection, final Collection<String> updatedCollection, final Collection<String> removedEntriesCollection) { for (final String string : oldCollection) { if (!updatedCollection.contains(string)) { removedEntriesCollection.add(string); }/*from www. j a va2s.c o m*/ } }
From source file:Main.java
public static void removeHightlights(final Collection<Highlighter.HighlightPainter> sample, Highlighter highlighter) { for (Highlight highlight : highlighter.getHighlights()) { if (sample.contains(highlight.getPainter())) { highlighter.removeHighlight(highlight); }/* ww w. j av a 2s . c om*/ } }
From source file:org.zalando.stups.tokens.util.Objects.java
public static <T extends Object> Collection<T> noNullEntries(String name, Collection<T> collection) { name = notBlank("name", name); collection = notNull(name, collection); try {/*from w ww.ja v a 2 s. c o m*/ if (collection.contains(null)) { throw new IllegalArgumentException(name + " should not contain 'null'"); } } catch (NullPointerException e) { return collection; } return collection; }
From source file:Main.java
public static <T> List<T> intersection(Collection<T> a, Collection<T> b) { ArrayList list = new ArrayList(); Iterator i$ = a.iterator();//from w w w .ja va 2 s . com while (i$.hasNext()) { Object element = i$.next(); if (b.contains(element)) { list.add(element); } } return list; }
From source file:Main.java
/** * Adds all non-null objects into the specified list. * * @param collection list to fill//from ww w . ja va2 s . c o m * @param objects objects * @param <T> objects type * @return true if list changed as the result of this operation, false otherwise */ public static <T> boolean addAllNonNull(final Collection<T> collection, final Collection<T> objects) { boolean result = false; for (final T object : objects) { if (!collection.contains(object) && object != null) { result |= collection.add(object); } } return result; }
From source file:Main.java
public static Collection rightDifference(final Collection c1, final Collection c2) { final List result = new ArrayList(); final Object[] members_c1 = c1.toArray(); for (int i = 0; i < members_c1.length; i++) { if (!c2.contains(members_c1[i])) { result.add(members_c1[i]);// ww w .j av a2s .c om } } return result; }
From source file:Main.java
/** * Check whether the given element is contained in the given scopes. * * @param element element to checking//w ww . ja v a 2 s . c om * @param scopes scopes to checking element * @param <T> element type * @return checking result. */ public static <T> boolean contains(T element, Collection<T> scopes) { Assert.notNull(element, "Element to checking must not be null."); Assert.notNull(scopes, "Checking scopes must not be null."); return scopes.contains(element); }
From source file:Main.java
public static <T> Set<T> intersection(Collection<? extends T> c1, Collection<? extends T> c2) { Set<T> result = new HashSet<T>(); for (Iterator<? extends T> it = c1.iterator(); it.hasNext();) { T element = it.next();/* www.j a v a2s .c o m*/ if (c2.contains(element)) result.add(element); } return result; }
From source file:Main.java
/** * the intersection of two collections./*from w ww . jav a2s . c om*/ * * @param c1 * collection1. * @param c2 * collection2. * @return the intersection, i.e. all elements that are in both collections. * @since 0.1 */ public static Collection intersection(final Collection c1, final Collection c2) { final List list = new ArrayList(); final Object[] members_c1 = c1.toArray(); for (int i = 0; i < members_c1.length; i++) { if (c2.contains(members_c1[i])) { list.add(members_c1[i]); } } return list; }
From source file:Main.java
public static Collection intersection(Collection a, Collection b) { Collection results = new HashSet(); for (Iterator i = a.iterator(); i.hasNext();) { Object o = i.next();// ww w . j ava 2 s . c om if (b.contains(o)) { results.add(o); } } return results; }