List of usage examples for java.util Collection contains
boolean contains(Object o);
From source file:com.cnksi.core.tools.utils.Collections3.java
/** * abList.//from w w w . j a va 2 s . com */ public static <T> List<T> intersection(Collection<T> a, Collection<T> b) { List<T> list = new ArrayList<T>(); for (T element : a) { if (b.contains(element)) { list.add(element); } } return list; }
From source file:Main.java
public static boolean containsAny(Collection source, Collection candidates) { if (!isEmpty(source) && !isEmpty(candidates)) { Iterator it = candidates.iterator(); do {//from www. j a v a 2 s . c om if (!it.hasNext()) { return false; } } while (!source.contains(it.next())); return true; } else { return false; } }
From source file:Main.java
public static Collection and(Collection collection1, Collection collection2) { Vector completeList = new Vector(); if (collection2 == null) return completeList; Iterator i = collection2.iterator(); while (i.hasNext()) { Object addlItem = i.next(); if (collection1.contains(addlItem) == true) { completeList.addElement(addlItem); }/* w w w . j a va2 s . c om*/ } return completeList; }
From source file:com.cloudera.oryx.common.OryxTest.java
public static <T> void assertContains(Collection<T> collection, T value) { assertTrue(abbreviatedToString(collection) + " should contain " + value, collection.contains(value)); }
From source file:net.ontopia.topicmaps.db2tm.Utils.java
/** * INTERNAL: Returns a map where the keys are data sources and each * entry is a collection of their individual relations. Before * returning all relations will be verified against the relations * declared in the mapping. If relations are missing an error is * issued indicating which ones are missing. *///from w w w. ja v a2 s . c o m public static Map<DataSourceIF, Collection<Relation>> verifyRelationsForMapping(RelationMapping rmapping) { // build return value Collection<DataSourceIF> ds = rmapping.getDataSources(); Map<DataSourceIF, Collection<Relation>> foundRelations = new HashMap<DataSourceIF, Collection<Relation>>( ds.size()); for (DataSourceIF datasource : ds) { foundRelations.put(datasource, datasource.getRelations()); } // detect missing relations List<Relation> missingRelations = new ArrayList<Relation>(); for (Relation relation : rmapping.getRelations()) { boolean relationMapped = false; for (Collection<Relation> frels : foundRelations.values()) { if (frels.contains(relation)) { relationMapped = true; break; } ; } if (!relationMapped) missingRelations.add(relation); } // complain if found mappings without relations int size = missingRelations.size(); if (size > 1) { String[] relnames = new String[size]; for (int i = 0; i < relnames.length; i++) { relnames[i] = missingRelations.get(i).getName(); } throw new DB2TMException("No relations found for mappings: " + StringUtils.join(relnames, ", ")); } else if (size == 1) { throw new DB2TMException("No relation found for mapping: " + missingRelations.get(0).getName()); } return foundRelations; }
From source file:com.cloudera.oryx.common.OryxTest.java
public static <T> void assertNotContains(Collection<T> collection, T value) { assertFalse(abbreviatedToString(collection) + " should not contain " + value, collection.contains(value)); }
From source file:com.reachlocal.grails.plugins.cassandra.utils.OrmHelper.java
public static boolean containsElement(Collection col1, Collection col2) { for (Object obj : col1) { if (col2.contains(obj)) { return true; }/* www . j a v a 2 s .co m*/ } return false; }
From source file:org.codehaus.groovy.grails.plugins.searchable.SearchableUtils.java
/** * Returns the class type of the searchable property * @param property// ww w. ja va 2 s.c o m * @param searchableGrailsDomainClasses * @return */ public static Class getSearchablePropertyAssociatedClass(GrailsDomainClassProperty property, Collection searchableGrailsDomainClasses) { Assert.notNull(property, "property cannot be null"); Assert.notNull(property.getDomainClass(), "grailsDomainClass cannot be null"); Class propertyType = property.getType(); Collection classes = getClasses(searchableGrailsDomainClasses); if (classes.contains(propertyType)) { return propertyType; } propertyType = property.getDomainClass().getRelatedClassType(property.getName()); if (propertyType != null && classes.contains(propertyType)) { return propertyType; } return null; }
From source file:com.evolveum.openicf.lotus.util.DominoUtils.java
public static boolean isAttrToGet(Collection attrs, String attrName) { return attrs.contains(attrName); }
From source file:Main.java
/** * Computes the array of element indices which where added to a collection. * * @param smallCollection/*from w w w. j a v a 2s .c o m*/ * the original collection. * @param bigCollection * the collection with added elements. * @return the the array of element indices which where added to the original * collection */ public static int[] computeDifferenceIndices(Collection<?> smallCollection, Collection<?> bigCollection) { List<Integer> addedIndices = new ArrayList<>(); int index = 0; for (Iterator<?> ite = bigCollection.iterator(); ite.hasNext(); index++) { if (smallCollection == null || !smallCollection.contains(ite.next())) { if (smallCollection == null) { ite.next(); } addedIndices.add(index); } } int[] result = new int[addedIndices.size()]; for (int i = 0; i < addedIndices.size(); i++) { result[i] = addedIndices.get(i); } return result; }