List of usage examples for java.util.stream Stream empty
public static <T> Stream<T> empty()
From source file:fr.cph.stock.external.impl.ExternalDataAccessImpl.java
@Override public final Stream<Company> getCompanyDataHistory(final String yahooId, final Date from, final Date to) { final String startDate = SIMPLE_DATE_FORMAT.format(from); final Calendar cal = Calendar.getInstance(); final String endDate = to == null ? SIMPLE_DATE_FORMAT.format(cal.getTime()) : SIMPLE_DATE_FORMAT.format(to); final String request = "select * from yahoo.finance.historicaldata where symbol = \"" + yahooId + "\" and startDate = \"" + startDate + "\" and endDate = \"" + endDate + "\""; final HistoryResult historyResult = yahooGateway.getObject(request, HistoryResult.class); final List<fr.cph.stock.external.web.currency.history.Quote> listResult = historyResult.getQuery() .getResults().getQuote();/* w w w .j av a2 s . c om*/ return listResult != null ? listResult.stream() .map(quote -> Company.builder().quote(quote.getClose()).yahooId(yahooId).build()) : Stream.empty(); }
From source file:org.lightjason.agentspeak.beliefbase.view.CViewMap.java
@Nonnull @Override//from www. j a v a 2s . c om public final Stream<IView> root() { return this.hasParent() ? Stream.concat(Stream.of(this), Stream.of(this.parent()).flatMap(IView::root)) : Stream.empty(); }
From source file:org.opennms.features.topology.plugins.topo.graphml.GraphMLEdgeStatusProvider.java
private GraphMLEdgeStatus computeEdgeStatus(final List<StatusScript> scripts, final GraphMLEdge edge) { return scripts.stream().flatMap(script -> { final SimpleBindings bindings = createBindings(edge); final StringWriter writer = new StringWriter(); final ScriptContext context = new SimpleScriptContext(); context.setWriter(writer);//from w w w . ja va2s.co m context.setBindings(bindings, ScriptContext.GLOBAL_SCOPE); try { LOG.debug("Executing script: {}", script); final GraphMLEdgeStatus status = script.eval(context); if (status != null) { return Stream.of(status); } else { return Stream.empty(); } } catch (final ScriptException e) { LOG.error("Failed to execute script: {}", e); return Stream.empty(); } finally { LOG.info(writer.toString()); } }).reduce(GraphMLEdgeStatus::merge).orElse(null); }
From source file:org.openthinclient.pkgmgr.UpdateDatabase.java
private Stream<Package> parsePackagesList(LocalPackageList localPackageList) { LOG.info("Processing packages for {}", localPackageList.getSource().getUrl()); try {//from w w w .j a va 2s. co m return new PackagesListParser().parse(Files.newInputStream(localPackageList.getPackagesFile().toPath())) .stream().map(p -> { p.setSource(localPackageList.getSource()); return p; }); } catch (IOException e) { LOG.error("Failed to parse packages list for " + localPackageList.getSource().getUrl(), e); return Stream.empty(); } }
From source file:org.everit.json.schema.ObjectSchema.java
private Stream<String> getAdditionalProperties(final JSONObject subject) { String[] names = JSONObject.getNames(subject); if (names == null) { return Stream.empty(); } else {/* w ww.java2s.c o m*/ return Arrays.stream(names).filter(key -> !propertySchemas.containsKey(key)) .filter(key -> !matchesAnyPattern(key)); } }
From source file:com.intuit.wasabi.repository.cassandra.impl.CassandraAssignmentsRepository.java
Stream<ExperimentUserByUserIdContextAppNameExperimentId> getUserIndexStream(String userId, String appName, String context) {//from w w w.j av a 2s . c o m Stream<ExperimentUserByUserIdContextAppNameExperimentId> resultStream = Stream.empty(); try { final Result<ExperimentUserByUserIdContextAppNameExperimentId> result = experimentUserIndexAccessor .selectBy(userId, appName, context); resultStream = StreamSupport .stream(Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve assignments for " + "experimentID = \"" + appName + "\" userID = \"" + userId + "\" and context " + context, e); } return resultStream; }
From source file:org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetrics.java
private Stream<Timed> findTimedAnnotations(AnnotatedElement element) { Timed timed = AnnotationUtils.findAnnotation(element, Timed.class); if (timed != null) { return Stream.of(timed); }/*from www . j a v a 2s. c o m*/ TimedSet ts = AnnotationUtils.findAnnotation(element, TimedSet.class); if (ts != null) { return Arrays.stream(ts.value()); } return Stream.empty(); }
From source file:org.lightjason.agentspeak.beliefbase.view.CViewMap.java
@Nonnull @Override/*from ww w. ja v a2 s . c o m*/ public final Stream<ILiteral> stream(final boolean p_negated, @Nullable final IPath... p_path) { return p_negated ? Stream.empty() : this.stream(p_path); }
From source file:alfio.manager.WaitingQueueManager.java
Stream<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> distributeSeats( Event event) {// w ww. jav a 2s . c o m int eventId = event.getId(); List<WaitingQueueSubscription> subscriptions = waitingQueueRepository.loadAllWaiting(eventId); int waitingPeople = subscriptions.size(); int waitingTickets = ticketRepository.countWaiting(eventId); if (waitingPeople == 0 && waitingTickets > 0) { ticketRepository.revertToFree(eventId); } else if (waitingPeople > 0 && waitingTickets > 0) { return distributeAvailableSeats(event, waitingPeople, waitingTickets); } else if (subscriptions.stream().anyMatch(WaitingQueueSubscription::isPreSales) && configurationManager.getBooleanConfigValue( Configuration.from(event.getOrganizationId(), event.getId(), ENABLE_PRE_REGISTRATION), false)) { return handlePreReservation(event, waitingPeople); } return Stream.empty(); }