List of usage examples for java.lang Iterable iterator
Iterator<T> iterator();
From source file:io.orchestrate.client.integration.FetchTest.java
@Test public void fetchEmptyEventsForNotFoundObject() throws InterruptedException, ExecutionException, TimeoutException { final String key = generateString(); final String eventType = generateString(); EventFetchOperation<String> eventFetchOp = new EventFetchOperation<String>(TEST_COLLECTION, key, eventType, String.class); Iterable<Event<String>> results = result(eventFetchOp); assertFalse(results.iterator().hasNext()); }
From source file:org.jasig.portlet.survey.service.jpa.JpaSurveyDao.java
@Override @SuppressWarnings("unchecked") public List<JpaSurvey> getAllSurveys() { Iterable<?> surveyIter = surveyRepository.findAll(); List<JpaSurvey> surveyList = IteratorUtils.toList(surveyIter.iterator()); return surveyList; }
From source file:corner.orm.hibernate.impl.PaginatedEntityService.java
License:asdf
public Iterator find(final Class<?> persistClass, final Object conditions, final String order, final int start, final int offset) { return (Iterator) this.template.execute(new HibernateCallback() { /**// w w w . ja v a2s.c o m * @see org.springframework.orm.hibernate3.HibernateCallback#doInHibernate(org.hibernate.Session) */ @Override public Object doInHibernate(final Session session) throws HibernateException, SQLException { Iterable con = typeCoercer.coerce(conditions, Iterable.class); final Iterator it = con == null ? null : con.iterator(); final StringBuffer sb = buildConditionHQL(persistClass, it); appendOrder(sb, order); sb.insert(0, SELECT_ID_CLAUSE); Query query = session.createQuery(sb.toString()); if (it != null) { int i = 0; while (it.hasNext()) { query.setParameter(i++, it.next()); } } query.setFirstResult(start); query.setMaxResults(offset); ResultTransformer transformer = new LazyLoadEntityTransformer(session, persistClass); query.setResultTransformer(transformer); List list = query.list(); return list.iterator(); } }); }
From source file:com.github.rvesse.airline.builder.CliBuilder.java
public CliBuilder<C> withCommands(Iterable<Class<? extends C>> commands) { this.defaultCommandGroupCommands .addAll(ListUtils.unmodifiableList(IteratorUtils.toList(commands.iterator()))); return this; }
From source file:io.druid.query.timeboundary.TimeBoundaryQueryRunnerTest.java
@Test public void testMergeResultsEmptyResults() throws Exception { List<Result<TimeBoundaryResultValue>> results = Lists.newArrayList(); TimeBoundaryQuery query = new TimeBoundaryQuery(new TableDataSource("test"), null, null, null, null); Iterable<Result<TimeBoundaryResultValue>> actual = query.mergeResults(results); Assert.assertFalse(actual.iterator().hasNext()); }
From source file:io.druid.query.timeboundary.TimeBoundaryQueryRunnerTest.java
@Test public void testMergeResults() throws Exception { List<Result<TimeBoundaryResultValue>> results = Arrays.asList( new Result<>(new DateTime(), new TimeBoundaryResultValue( ImmutableMap.of("maxTime", "2012-01-01", "minTime", "2011-01-01"))), new Result<>(new DateTime(), new TimeBoundaryResultValue( ImmutableMap.of("maxTime", "2012-02-01", "minTime", "2011-01-01")))); TimeBoundaryQuery query = new TimeBoundaryQuery(new TableDataSource("test"), null, null, null, null); Iterable<Result<TimeBoundaryResultValue>> actual = query.mergeResults(results); Assert.assertTrue(actual.iterator().next().getValue().getMaxTime().equals(new DateTime("2012-02-01"))); }
From source file:org.openbaton.vnfm.core.ApplicationManagement.java
public Set<Application> queryByVnfrId(String vnfrId) throws NotFoundException { log.debug("Listing all Applications running on VNFR with id: " + vnfrId); Iterable<Application> appsIterable = applicationRepository.findAppByVnfrId(vnfrId); if (!appsIterable.iterator().hasNext()) { //throw new NotFoundException("Not found any Applications running on VNFR with id: " + vnfrId); return new HashSet<>(); }/*from w w w. j a v a 2 s . co m*/ return fromIterbaleToSet(appsIterable); }
From source file:com.simphony.managedbeans.SalePointBean.java
/** * Llenamos lista de agremiados// ww w. ja v a 2 s .c o m */ private void fillSalePoint() { list.clear(); Iterable<SalePoint> c = this.salePointService.getSalePointRepository().findAll(sortByDescription()); Iterator<SalePoint> cu = c.iterator(); while (cu.hasNext()) { list.add(cu.next()); } }
From source file:org.openbaton.vnfm.core.ApplicationManagement.java
public void deleteByVnfrId(String vnfrId) throws NotFoundException { log.debug("Removing all Applications running on VNFR with id: " + vnfrId); Iterable<Application> appsIterable = applicationRepository.findAppByVnfrId(vnfrId); if (!appsIterable.iterator().hasNext()) { log.warn("Not found any Applications running on VNFR with id: " + vnfrId); return;/* w ww . j ava2 s . co m*/ } Iterator<Application> iterator = appsIterable.iterator(); while (iterator.hasNext()) { delete(vnfrId, iterator.next().getId()); } log.info("Removed all Applications running on VNFR with id: " + vnfrId); }
From source file:com.simphony.managedbeans.CostBean.java
private void fillCosts() { list.clear();//w w w . j a v a 2 s . c o m Iterable<Cost> c = this.getCostService().getCostRepository().findAll(sortByOrigin()); Iterator<Cost> cu = c.iterator(); while (cu.hasNext()) { list.add(cu.next()); } }