List of usage examples for java.util.stream Stream concat
public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)
From source file:org.lightjason.agentspeak.action.builtin.TestCActionBool.java
/** * data provider generator/*from w ww . j av a 2 s . c om*/ * @return data */ @DataProvider public static Object[] generate() { return Stream.concat( // -- first test-case --- testcase( // input data Stream.of(true, false, true, false, false, true), // testing classes / test-methods Stream.of(CAllMatch.class, CAnyMatch.class, CAnd.class, COr.class, CXor.class, CNot.class, CCountTrue.class, CCountFalse.class), // results for each class test Stream.of(false), Stream.of(true), Stream.of(false), Stream.of(true), Stream.of(true), Stream.of(false, true, false, true, true, false), Stream.of(3L), Stream.of(3L)), // --- second test-case --- testcase( // input data Stream.of(true, true), // testing classes / test-methods Stream.of(CAllMatch.class, CAnyMatch.class, CAnd.class, COr.class, CXor.class, CNot.class, CCountTrue.class, CCountFalse.class ), // results for each class test Stream.of(true), Stream.of(true), Stream.of(true), Stream.of(true), Stream.of(false), Stream.of(false, false), Stream.of(2L), Stream.of(0L)) ).toArray(); }
From source file:org.springframework.integration.test.rule.Log4j2LevelAdjuster.java
private Log4j2LevelAdjuster(Level level, Class<?>[] classes, String[] categories) { Assert.notNull(level, "'level' must be null"); this.level = level; this.classes = classes != null ? classes : new Class<?>[0]; Stream<String> categoryStream = Stream.of(getClass().getPackage().getName()); if (!ObjectUtils.isEmpty(categories)) { categoryStream = Stream.concat(Arrays.stream(categories), categoryStream); }/* www . j av a 2s.com*/ this.categories = categoryStream.toArray(String[]::new); }
From source file:com.wormsim.animals.AnimalStrain2Instance.java
@Override public String toCurrentValueString() { return Stream.concat(stages.values().stream(), developments.values().stream()) .filter((v) -> v.getParent().isVisiblyTracked()).map((v) -> v.toCurrentValueString()) .collect(Utils.TAB_JOINING); }
From source file:com.yahoo.bard.webservice.util.SimplifiedIntervalList.java
/** * Takes one or more lists of intervals, and combines them into a single, sorted list with the minimum number of * intervals needed to capture exactly the same instants as the original intervals. * <p>//w w w . java 2 s. c o m * If any subintervals of the input collection abut or overlap they will be replaced with a single, combined * interval. * <p> * Examples: * <ul> * <li>['2014/2017', '2015/2020'] will combine into ['2014/2020'] * <li>['2015/2016', '2016/2017'] will combine into ['2015/2017] * <li>['2015/2016', '2013/2014'] will sort into ['2013/2014', '2015/2016'] * <li>['2015/2015', '2015/2016', '2012/2013'] will sort and combine to ['2012/2013', '2015/2016'] * </ul> * @param intervals The collection(s) of intervals being collated * * @return A single list of sorted intervals simplified to the smallest number of intervals able to describe the * duration */ @SafeVarargs public static SimplifiedIntervalList simplifyIntervals(Collection<Interval>... intervals) { Stream<Interval> allIntervals = Stream.empty(); for (Collection<Interval> intervalCollection : intervals) { allIntervals = Stream.concat(allIntervals, intervalCollection.stream()); } return allIntervals.sorted(IntervalStartComparator.INSTANCE::compare).collect(getCollector()); }
From source file:ddf.catalog.history.DynamicMultiMetacardType.java
private Stream<AttributeDescriptor> streamAttributeDescriptors() { Stream<MetacardType> filteredTypes = metacardTypes.stream() .filter(mt -> !REGISTERED_DMMTS.contains(mt.getName())); return Stream.concat(filteredTypes, extraTypes.stream()).map(MetacardType::getAttributeDescriptors) .flatMap(Collection::stream); }
From source file:org.trellisldp.http.core.TimemapGenerator.java
/** * Generate RDF triples from mementos./*from ww w . j ava2 s.c om*/ * @param identifier the identifier * @param mementos the mementos * @return a stream of triples */ default Stream<Triple> asRdf(String identifier, List<Link> mementos) { final String timeIriPrefix = "http://reference.data.gov.uk/id/gregorian-instant/"; final RDF rdf = getInstance(); final IRI originalResource = rdf.createIRI(identifier); final List<Triple> descriptions = new ArrayList<>(); descriptions.add(rdf.createTriple(originalResource, type, Memento.OriginalResource)); descriptions.add(rdf.createTriple(originalResource, type, Memento.TimeGate)); descriptions.add(rdf.createTriple(originalResource, Memento.timegate, originalResource)); descriptions.add( rdf.createTriple(originalResource, Memento.timemap, rdf.createIRI(identifier + "?ext=timemap"))); mementos.stream().filter(link -> link.getRels().contains(MEMENTO)).map(link -> rdf .createTriple(originalResource, Memento.memento, rdf.createIRI(link.getUri().toString()))) .forEach(descriptions::add); return Stream.concat(descriptions.stream(), mementos.stream().flatMap(link -> { final String linkUri = link.getUri().toString(); final IRI iri = rdf.createIRI(linkUri); final Stream.Builder<Triple> buffer = Stream.builder(); // TimeMap triples if (link.getParams().containsKey(FROM)) { buffer.add(rdf.createTriple(iri, type, Memento.TimeMap)); buffer.add(rdf.createTriple(iri, Time.hasBeginning, rdf.createIRI( timeIriPrefix + parse(link.getParams().get(FROM), RFC_1123_DATE_TIME).toString()))); } if (link.getParams().containsKey(UNTIL)) { buffer.add(rdf.createTriple(iri, Time.hasEnd, rdf.createIRI( timeIriPrefix + parse(link.getParams().get(UNTIL), RFC_1123_DATE_TIME).toString()))); } // Memento triples if (isMementoLink(link)) { final IRI original = rdf.createIRI(linkUri.split("\\?")[0]); final IRI timemapUrl = rdf.createIRI(linkUri.split("\\?")[0] + "?ext=timemap"); buffer.add(rdf.createTriple(iri, type, Memento.Memento)); buffer.add(rdf.createTriple(iri, Memento.original, original)); buffer.add(rdf.createTriple(iri, Memento.timegate, original)); buffer.add(rdf.createTriple(iri, Memento.timemap, timemapUrl)); buffer.add(rdf.createTriple(iri, Time.hasTime, rdf.createIRI( timeIriPrefix + parse(link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString()))); buffer.add(rdf.createTriple(iri, Memento.mementoDatetime, rdf.createLiteral( parse(link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString(), XSD.dateTime))); } return buffer.build(); })); }
From source file:com.wormsim.animals.AnimalStage2.java
@Override public String toBetweenVarianceString() { return Stream .concat(Stream.concat(Stream.concat(Stream.of(food_rate), Stream.of(pheromone_rates)), Stream.of(dev_time)), Stream.of(development)) .filter((v) -> v.isVisiblyTracked()).map((v) -> v.toBetweenVarianceString()) .collect(Utils.TAB_JOINING); }
From source file:de.mg.stock.server.model.Stock.java
/** * @return list of all day prices filled up with instant prices, in case of missing day prices *//*from www . ja v a 2 s.co m*/ public Set<SimpleDayPrice> getAllPricesDaily() { getInstantPrices().stream().forEach(ip -> logger.info(ip.toString())); List<SimpleDayPrice> prices = Stream .concat(getDayPrices().stream().map(dp -> new SimpleDayPrice(dp.getDay(), dp.getAverage())), getInstantPrices().stream() .map(ip -> new SimpleDayPrice(ip.getTime().toLocalDate(), ip.getAverage()))) .collect(Collectors.toList()); Set<SimpleDayPrice> result = prices.stream() .collect(Collectors.groupingBy(SimpleDayPrice::getDate, Collectors.toSet())).entrySet().stream() .map(e -> new SimpleDayPrice(e.getKey(), (long) e.getValue().stream().mapToLong(SimpleDayPrice::getAverage).average().getAsDouble())) .collect(Collectors.toSet()); return result; }
From source file:com.ikanow.aleph2.analytics.hadoop.services.BeXmlParser.java
public BeXmlParser(final BeFileInputConfigBean.XML xml) { _xml = xml;/*from w w w . j a v a2 s . co m*/ // If any of the fields contain ":" then it's in "prefix mode", which means the prefixes are used to lookup root and ignore fields (but are still discarded from the JSON) _prefix_mode = Stream.concat(xml.root_fields().stream(), xml.ignore_fields().stream()) .anyMatch(s -> s.contains(":")); _factory.setProperty(XMLInputFactory.IS_COALESCING, true); _factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); }
From source file:nova.core.util.RayTracer.java
public Stream<RayTraceResult> rayTraceAll(World world) { return Stream.concat(rayTraceBlocks(world), rayTraceEntities(world)).sorted(); }