List of usage examples for java.lang Iterable iterator
Iterator<T> iterator();
From source file:org.agatom.springatom.web.validator.AppointmentValidator.java
private void validateOwner(final MessageContext messageContext, final MessageBuilder messageBuilder, final Locale locale, final NUser owner) { if (owner != null) { final Iterable<NIssue> all = this.issuesService.findForAssignee(owner); final Iterator<NIssue> iterator = all.iterator(); if (iterator.hasNext()) { final StringBuilder stringBuilder = new StringBuilder(); while (iterator.hasNext()) { final NIssue issue = iterator.next(); stringBuilder.append(this.messageSource.getMessage(issue.getType(), locale)).append(": ") .append(owner.getUsername()).append(" ").append(issue.getMessage()); if (ClassUtils.isAssignableValue(NAppointmentIssue.class, issue)) { final NAppointmentIssue appointmentIssue = (NAppointmentIssue) issue; stringBuilder.append("\n") .append(appointmentIssue.getAppointment().getBeginDate() .toString(this.messageSource.getMessage("data.format.value", locale))) .append("\n"); }/* ww w . ja va 2s. c o m*/ } messageContext.addMessage( messageBuilder.warning().source("car.owner").defaultText(stringBuilder.toString()).build()); } } }
From source file:edu.pitt.dbmi.ccd.anno.annotation.data.AnnotationDataResourceAssembler.java
/** * convert AnnotationDatas to AnnotationDataResources * * @param annotations entities//from ww w . ja v a2 s .c o m * @return List of resources */ @Override public List<AnnotationDataResource> toResources(Iterable<? extends AnnotationData> annotations) throws IllegalArgumentException { // Assert annotations is not empty Assert.isTrue(annotations.iterator().hasNext()); return StreamSupport.stream(annotations.spliterator(), false).map(this::toResource) .collect(Collectors.toList()); }
From source file:ar.com.zauber.commons.dao.IterableMerger.java
/** Realiza el merge aplicando el {@link Closure} */ public final void merge(final Iterable<T> iterableLeft, final Iterable<T> iterableRight) { Validate.notNull(iterableLeft);//from ww w .ja v a 2 s . com Validate.notNull(iterableRight); left = iterableLeft.iterator(); right = iterableRight.iterator(); forwardLeft(); forwardRight(); while (l != null && r != null) { int diff = comparator.compare(l, r); if (diff <= 0) { target.execute(l); forwardLeft(); } else { target.execute(r); forwardRight(); } } while (l != null) { target.execute(l); forwardLeft(); } while (r != null) { target.execute(r); forwardRight(); } }
From source file:com.littlehotspot.hadoop.mr.nginx.module.hdfs2hbase.api.user.UserReducer.java
@Override protected void reduce(Text key, Iterable<Text> value, Reducer<Text, Text, Text, Text>.Context context) throws IOException, InterruptedException { try {//w w w.j ava2 s. com Iterator<Text> textIterator = value.iterator(); TextTargetUserBean targetUserBean = new TextTargetUserBean(); while (textIterator.hasNext()) { Text item = textIterator.next(); if (item == null) { continue; } String rowLineContent = item.toString(); TextSourceUserBean sourceUserBean = new TextSourceUserBean(rowLineContent); targetUserBean.setDeviceId(sourceUserBean.getDeviceId()); targetUserBean.setDeviceType(sourceUserBean.getDeviceType()); targetUserBean.setMachineModel(sourceUserBean.getMachineModel()); targetUserBean.setSince(sourceUserBean.getChannelId()); // targetUserBean.setToken(); // targetUserBean.setDemandTime(); // targetUserBean.setProjectionTime(); this.setDownloadTime(sourceUserBean, targetUserBean); } CommonVariables.hBaseHelper.insert(targetUserBean); context.write(new Text(targetUserBean.rowLine()), new Text()); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.pitt.dbmi.ccd.anno.annotation.AnnotationResourceAssembler.java
/** * convert Annotations to AnnotationResources * * @param annotations entities//from ww w . ja va2s. c om * @return list of resources */ @Override public List<AnnotationResource> toResources(Iterable<? extends Annotation> annotations) throws IllegalArgumentException { // Assert annotations is not empty Assert.isTrue(annotations.iterator().hasNext()); return StreamSupport.stream(annotations.spliterator(), false).map(this::toResource) .collect(Collectors.toList()); }
From source file:org.axonframework.samples.trader.query.orderbook.OrderBookListenerIntegrationTest.java
@Test public void testHandleOrderBookCreatedEvent() throws Exception { OrderBookAddedToCompanyEvent event = new OrderBookAddedToCompanyEvent(companyId, orderBookId); orderBookListener.handleOrderBookAddedToCompanyEvent(event); Iterable<OrderBookEntry> all = orderBookRepository.findAll(); OrderBookEntry orderBookEntry = all.iterator().next(); assertNotNull("The first item of the iterator for orderbooks should not be null", orderBookEntry); assertEquals("Test Company", orderBookEntry.getCompanyName()); }
From source file:com.all.shared.model.TrackUtil.java
public void filterTracksWithoutMagnetLink(Iterable<Track> playlist) { Iterator<Track> trackIterator = playlist.iterator(); while (trackIterator.hasNext()) { Track track = trackIterator.next(); if (track.getDownloadString() == null) { log.warn("Track does not contain magnet link, removing it! " + track.getName()); trackIterator.remove();//ww w .j a v a2s.c om } } }
From source file:org.axonframework.samples.trader.query.orderbook.OrderBookListenerIntegrationTest.java
@Test public void testHandleBuyOrderPlaced() throws Exception { CompanyEntry company = createCompany(); OrderBookEntry orderBook = createOrderBook(company); BuyOrderPlacedEvent event = new BuyOrderPlacedEvent(orderBookId, orderId, transactionId, 300, 100, portfolioId);/*from w ww .j ava2 s . co m*/ orderBookListener.handleBuyOrderPlaced(event); Iterable<OrderBookEntry> all = orderBookRepository.findAll(); OrderBookEntry orderBookEntry = all.iterator().next(); assertNotNull("The first item of the iterator for orderbooks should not be null", orderBookEntry); assertEquals("Test Company", orderBookEntry.getCompanyName()); assertEquals(1, orderBookEntry.buyOrders().size()); assertEquals(300, orderBookEntry.buyOrders().get(0).getTradeCount()); }
From source file:com.google.code.polymate.CRUDTests.java
@Test public void testAddOrder() { Order order = new Order(); order.setOrderNumber("Order 1"); assertNotNull(polymate.save(order)); Iterable<Order> result = polymate.find(Order.class); assertNotNull(result);// ww w.ja v a 2s. c om assertTrue(result.iterator().hasNext()); Order order2 = result.iterator().next(); assertNotNull(order2); assertEquals(order.getOrderNumber(), order2.getOrderNumber()); }
From source file:io.syndesis.git.GitWorkflow.java
private void commitAndPush(Git git, String authorName, String authorEmail, String message, UsernamePasswordCredentialsProvider credentials) throws GitAPIException { // git add ./*ww w . j a va 2s. c o m*/ git.add().addFilepattern(".").call(); if (LOG.isDebugEnabled()) { LOG.debug("git add all file"); } // git commit RevCommit commit = git.commit().setAuthor(authorName, authorEmail).setMessage(message).call(); LOG.info("git commit id {}", commit.getId()); // git push -f, not merging but simply forcing the push (for now) Iterable<PushResult> pushResult = git.push().setCredentialsProvider(credentials).setForce(true).call(); if (!pushResult.iterator().next().getMessages().equals("")) { LOG.warn("git push messages: {}", pushResult.iterator().next().getMessages()); } }