List of usage examples for java.lang Iterable iterator
Iterator<T> iterator();
From source file:org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.java
/** * Converts an iterable of relationships to project relationships detached from database. * * @param relationships iterable of {@link AbstractNeoProjectRelationship} or {@link Relationship} * @return list of detached relationships * @throws IllegalArgumentException if an iterable of unsupported classes is passed *///from w w w . ja v a 2 s . com public static List<ProjectRelationship<?, ?>> convertToDetachedRelationships(final Iterable<?> relationships) { final List<ProjectRelationship<?, ?>> rels = new ArrayList<ProjectRelationship<?, ?>>(); Iterator<?> iterator = relationships.iterator(); while (iterator.hasNext()) { final AbstractNeoProjectRelationship<?, ?, ?> rel; Object next = iterator.next(); if (next instanceof AbstractNeoProjectRelationship) { rel = (AbstractNeoProjectRelationship<?, ?, ?>) next; } else if (next instanceof Relationship) { rel = Conversions.toProjectRelationship((Relationship) next); } else { throw new IllegalArgumentException("Relationship class " + next.getClass().getCanonicalName() + " cannot be converted to detached relationship."); } if (rel != null) { rels.add(rel.detach()); } } return rels; }
From source file:com.github.rvesse.airline.model.MetadataLoader.java
/** * Loads command meta-data/* www. j ava2 s .c o m*/ * * @param defaultCommands * Default command classes * @return Command meta-data */ public static <T> List<CommandMetadata> loadCommands(Iterable<Class<? extends T>> defaultCommands) { List<CommandMetadata> commandMetadata = new ArrayList<CommandMetadata>(); Iterator<Class<? extends T>> iter = defaultCommands.iterator(); while (iter.hasNext()) { commandMetadata.add(loadCommand(iter.next())); } return commandMetadata; }
From source file:com.drazzib.neo4j.PubServiceTest.java
@Test public void testCreateBeer() { assertEquals(0, service.getBeersCount()); Beer myBeer = service.createBeer("mine", 0); assertEquals(1, service.getBeersCount()); Iterable<Beer> founds = service.getAllBeers(); Beer mine = founds.iterator().next(); assertEquals(myBeer.getName(), mine.getName()); }
From source file:de.dhke.projects.cutil.collections.iterator.MultiMapEntryIterator.java
protected MultiMapEntryIterator(final Iterable<Map.Entry<K, Collection<V>>> baseIterable) { _baseIter = baseIterable.iterator(); /* advance to first value collection */ if (_baseIter.hasNext()) { final Map.Entry<K, Collection<V>> entry = _baseIter.next(); _currentKey = entry.getKey();/*from w w w. j a va2 s . com*/ _currentValueCollection = entry.getValue().iterator(); } advance(); }
From source file:org.osmsurround.ae.filter.NodeFilterService.java
public void filterAmenitiesForUser(Iterable<Amenity> amenities, FilterSet userFilterSet) { for (Iterator<Amenity> it = amenities.iterator(); it.hasNext();) { Amenity amenity = it.next();/*from ww w. j av a 2s.c om*/ Filter filter = checkFilter(userFilterSet, amenity.getKeyValues()); if (filter == null) { it.remove(); } else amenity.setMatchedIcon(filter.getIcon()); } }
From source file:example.springdata.jpa.showcase.after.CustomerRepositoryIntegrationTest.java
@Test public void findsAllCustomers() throws Exception { Iterable<Customer> result = repository.findAll(); assertThat(result, is(notNullValue())); assertTrue(result.iterator().hasNext()); }
From source file:de.kaiserpfalzEdv.infopir.backend.court.impl.RegisterServiceImpl.java
@Override @Transactional(readOnly = true)//from ww w . j a va 2s .com public RegisterEntry retrieve(RegisterQuery query) throws EntityNotFoundException, NoSingleEntityFoundException { Predicate q = new RegisterPredicateBuilder().withQuery(query).build(); Iterable<RegisterEntry> dbResult = repository.findAll(q); Iterator<RegisterEntry> it = dbResult.iterator(); if (!it.hasNext()) throw new EntityNotFoundException(RegisterEntry.class, q.toString()); RegisterEntry result = it.next(); if (it.hasNext()) throw new NoSingleEntityFoundException(RegisterEntry.class, q.toString()); return result; }
From source file:br.com.ajaio.midas.desktop.controller.BancoCrudFXMLController.java
public void consultar() { try {//from w ww .ja v a 2s .c om BancoEntity filtro = new BancoEntity(); BancoService bancoService = (BancoService) context.getBean("bancoService"); Iterable<BancoEntity> bancos = bancoService.findAll(); Iterator itBanco = bancos.iterator(); ArrayList<Banco> bancosDM = new ArrayList<Banco>(); for (BancoEntity b : bancos) { Banco banco = new Banco(b); bancosDM.add(banco); } final ObservableList<Banco> data = FXCollections.observableArrayList(bancosDM); tbBancos.setItems(data); } catch (Exception e) { tratarExcecao(e); } }
From source file:com.gargoylesoftware.htmlunit.source.JQueryExtractorSample.java
/** * Loads the jQuery unit test index page using the specified browser version, allows its * JavaScript to run to completion, and returns a list item iterator containing the test * results./* ww w . j a v a 2s .co m*/ * * @return a list item iterator containing the test results * @throws Exception if an error occurs */ protected Iterator<HtmlElement> loadPage() throws Exception { final String resource = "jquery/" + getVersion() + "/test/index.html"; final URL url = getClass().getClassLoader().getResource(resource); assertNotNull(url); final WebClient client = getWebClient(); final HtmlPage page = client.getPage(url); client.waitForBackgroundJavaScript(2 * 60 * 1000); // dump the result page if not OK if (System.getProperty(PROPERTY_GENERATE_TESTPAGES) != null) { final File tmpDir = new File(System.getProperty("java.io.tmpdir")); final File f = new File(tmpDir, "jquery" + getVersion() + '_' + getBrowserVersion().getNickname() + "_result.html"); FileUtils.writeStringToFile(f, page.asXml(), "UTF-8"); LOG.info("Test result for " + getVersion() + '_' + getBrowserVersion().getNickname() + " written to: " + f.getAbsolutePath()); } final HtmlElement doc = page.getDocumentElement(); final HtmlOrderedList tests = (HtmlOrderedList) doc.getElementById("tests"); final Iterable<HtmlElement> i = tests.getChildElements(); return i.iterator(); }
From source file:com.sqewd.open.dal.core.persistence.query.ConditionMatcher.java
@SuppressWarnings("unchecked") protected <T> boolean isListEntityType(final Object src) { Iterable<T> entities = (Iterable<T>) src; if (entities != null && entities.iterator().hasNext()) { T value = entities.iterator().next(); if (value instanceof AbstractEntity) return true; }//from w w w . j a va2 s.c o m return false; }