List of usage examples for java.util Collection add
boolean add(E e);
From source file:au.com.jwatmuff.eventmanager.model.misc.SessionLockerTest.java
private static Session setupUnlockedSession(TransactionalDatabase database) throws IOException { Session session = null;/*from w w w. j a v a2s.c o m*/ try { CSVImporter.importPlayers(new File("test/player_test_data.csv"), database); CSVImporter.importPools(new File("test/pool_test_data.csv"), database); CompetitionInfo ci = new CompetitionInfo(); Calendar cal = new GregorianCalendar(2008, 1, 1); ci.setStartDate(cal.getTime()); cal.roll(GregorianCalendar.DATE, 2); ci.setEndDate(cal.getTime()); ci.setAgeThresholdDate(cal.getTime()); ci.setName("My Comp"); ci.setMats(1); database.add(ci); // lock all players so they can be assigned to pools for (Player p : database.findAll(Player.class, PlayerDAO.ALL)) { p.setWeight(65.0); database.update(p); PlayerLocker.lockPlayer(database, p); } AutoAssign.assignPlayersToPools(database); Pool pool = database.findAll(Pool.class, PoolDAO.WITH_PLAYERS).iterator().next(); for (PlayerPool pp : database.findAll(PlayerPool.class, PlayerPoolDAO.FOR_POOL, pool.getID())) { pp.setApproved(true); database.update(pp); } pool = PoolLocker.lockPoolPlayers(database, pool); FightGenerator.generateFightsForPool(database, pool); pool = PoolLocker.lockPoolFights(database, pool); Session mat = new Session(); mat.setType(Session.SessionType.MAT); mat.setMat("Mat"); database.add(mat); session = new Session(); session.setType(Session.SessionType.NORMAL); session.setName("Session"); Collection<Session> preceding = new ArrayList<Session>(); Collection<Pool> pools = new ArrayList<Pool>(); pools.add(pool); SessionLinker.insertSession(database, session, mat, preceding, pools); } catch (DatabaseStateException ex) { fail(ex.getMessage()); } return session; }
From source file:Main.java
private static void addImports(Attributes attrigutes, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) { ExportPackageDescription[] exports = compositeDesc.getExportPackages(); List systemExports = getSystemExports(matchingExports); if (exports.length == 0 && systemExports.size() == 0) return;/* w w w . java 2 s . co m*/ StringBuffer importStatement = new StringBuffer(); Collection importedNames = new ArrayList(exports.length); int i = 0; for (; i < exports.length; i++) { if (i != 0) importStatement.append(','); importedNames.add(exports[i].getName()); getImportFrom(exports[i], importStatement); } for (Iterator iSystemExports = systemExports.iterator(); iSystemExports.hasNext();) { ExportPackageDescription systemExport = (ExportPackageDescription) iSystemExports.next(); if (!importedNames.contains(systemExport.getName())) { if (i != 0) importStatement.append(','); i++; importStatement.append(systemExport.getName()).append(ELEMENT_SEPARATOR) .append(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE).append('=') .append(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); } } attrigutes.putValue(Constants.IMPORT_PACKAGE, importStatement.toString()); }
From source file:Main.java
/** * Add all elements of an {@link Enumeration} to a {@link Collection}. * // w ww .j a va2s . c om * @param collection * to add from enumeration. * @param enumeration * to add to collection. * @return true if collection is modified, otherwise false. * @since 8.1 * @see Collection#addAll(Collection) */ public static final <T> boolean addAll(final Collection<T> collection, final Enumeration<T> enumeration) { if (null == enumeration) { return false; } boolean modified = false; while (enumeration.hasMoreElements()) { modified |= collection.add(enumeration.nextElement()); } return modified; }
From source file:com.google.code.guice.repository.configuration.ScanningJpaRepositoryModule.java
private static String[] extractPersistenceUnitsNames(Iterable<RepositoriesGroup> repositoriesGroups) { Collection<String> persistenceUnitsNames = new ArrayList<String>(); for (RepositoriesGroup repositoriesGroup : repositoriesGroups) { persistenceUnitsNames.add(repositoriesGroup.getPersistenceUnitName()); }//from w ww . ja v a 2s.c o m return persistenceUnitsNames.toArray(new String[persistenceUnitsNames.size()]); }
From source file:com.egt.ejb.toolkit.ColUtils.java
public static <T> Collection<T> filterAny(Collection<T> collection, Predicado<T>... predicates) { Collection<T> arrayList = new ArrayList<T>(); for (T element : collection) { for (Predicado<T> predicate : predicates) { if (predicate.evaluate(element)) { arrayList.add(element); break; }/*from ww w . j av a2 s . co m*/ } } return arrayList; }
From source file:net.roboconf.dm.templating.internal.helpers.AllHelper.java
/** * Returns all the descendant instances of the given instance. * @param instance the instance which descendants must be retrieved. * @return the descendants of the given instance. */// w w w. j ava2 s . com private static Collection<InstanceContextBean> descendantInstances(final InstanceContextBean instance) { final Collection<InstanceContextBean> result = new ArrayList<InstanceContextBean>(); for (final InstanceContextBean child : instance.getChildren()) { result.add(child); result.addAll(descendantInstances(child)); } return result; }
From source file:edu.uci.ics.asterix.installer.transaction.RecoveryIT.java
@Parameters public static Collection<Object[]> tests() throws Exception { Collection<Object[]> testArgs = new ArrayList<Object[]>(); TestCaseContext.Builder b = new TestCaseContext.Builder(); for (TestCaseContext ctx : b.build(new File(PATH_BASE))) { testArgs.add(new Object[] { ctx }); }/*from ww w . jav a 2s.co m*/ return testArgs; }
From source file:Main.java
/** * Merge the given array into the given Collection. * * @param array the array to merge (may be {@code null}) * @param collection the target Collection to merge the array into *//* ww w . j a v a 2 s . c om*/ @SuppressWarnings("unchecked") public static <E> void mergeArrayIntoCollection(Object array, Collection<E> collection) { if (collection == null) { throw new IllegalArgumentException("Collection must not be null"); } Object[] arr = org.springframework.util.ObjectUtils.toObjectArray(array); for (Object elem : arr) { collection.add((E) elem); } }
From source file:org.openscore.lang.compiler.scorecompiler.ScoreCompilerImpl.java
private static Collection<Input> getSystemProperties(List<Input> inputs) { Collection<Input> result = new ArrayList<>(); for (Input input : inputs) { if (input.getSystemPropertyName() != null) result.add(input); }//w w w .j av a2 s . co m return result; }
From source file:com.stratumsoft.xmlgen.SchemaUtil.java
/** * Get the top-level element qname's for the given XmlSchema * * @param xmlSchema//from w w w . ja v a2s . c om * @return */ public static Collection<QName> getElements(XmlSchema xmlSchema) { Collection<QName> elNames = new HashSet<QName>(); if (xmlSchema != null) { Map<QName, XmlSchemaElement> schElems = xmlSchema.getElements(); for (QName name : schElems.keySet()) { elNames.add(name); } } return elNames; }