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:com.ikanow.aleph2.search_service.elasticsearch.utils.ElasticsearchIndexUtils.java
/** Recursive function that will return all fields in an insert (eg "geoip", "geoip.location") * @param index//from ww w.j a v a 2 s .c o m * @return */ protected static Stream<String> getAllFixedFields_internal(final JsonNode index) { return Optional.ofNullable(index.get("properties")).filter(p -> !p.isNull()).map(p -> { if (!p.isObject()) throw new RuntimeException("properties must be object"); return p; }).map(p -> { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(p.fields(), Spliterator.ORDERED), false) .map(kv -> { return kv; }).<String>flatMap(kv -> { final Stream<String> parent_element = Stream.of(kv.getKey()); return Stream.concat(parent_element, getAllFixedFields_internal(kv.getValue()).map(s -> kv.getKey() + "." + s)); }); }).orElse(Stream.<String>empty()); }
From source file:org.apache.tajo.cli.tsql.TajoCli.java
private Collection<String> getKeywords() { // SQL reserved keywords Stream<String> tokens = Arrays.stream(SQLLexer.tokenNames); Stream<String> rules = Arrays.stream(SQLLexer.ruleNames); List<String> keywords = Stream.concat(tokens, rules) .filter((str) -> str.matches("[A-Z_]+") && str.length() > 1).distinct().map(String::toLowerCase) .collect(Collectors.toList()); // DB and table names for (String db : client.getAllDatabaseNames()) { keywords.add(db);// w w w . ja va 2 s . com keywords.addAll(client.getTableList(db)); } tokens.close(); rules.close(); return keywords; }
From source file:com.yahoo.bard.webservice.data.metric.TemplateDruidQuery.java
/** * Get the field by name./*from ww w . j a va2 s .co m*/ * * @param name Name of the field to retrieve * * @return The field if found, or null if we couldn't find a matching Field * @throws IllegalArgumentException if there is no MetricField with the given name */ public MetricField getMetricField(String name) { return Stream.concat(postAggregations.stream(), aggregations.stream()) .filter(field -> field.getName().equals(name)).findAny().orElseThrow(IllegalArgumentException::new); }
From source file:it.unibo.alchemist.model.implementations.environments.AbstractEnvironment.java
private Queue<Operation> toQueue(final Node<T> center, final Neighborhood<T> oldNeighborhood, final Neighborhood<T> newNeighborhood) { return Stream .concat(lostNeighbors(center, oldNeighborhood, newNeighborhood), foundNeighbors(center, oldNeighborhood, newNeighborhood)) .collect(Collectors.toCollection(LinkedList::new)); }
From source file:com.github.helenusdriver.driver.impl.RootClassInfoImpl.java
/** * {@inheritDoc}//from w w w. j av a 2 s .co m * * @author paouelle * * @see com.github.helenusdriver.driver.impl.ClassInfoImpl#objectClasses() */ @Override public Stream<Class<? extends T>> objectClasses() { return Stream.concat(Stream.of(clazz), ctypes.values().stream().map(t -> t.getObjectClass())); }
From source file:com.github.helenusdriver.driver.impl.RootClassInfoImpl.java
/** * {@inheritDoc}//from ww w .ja va 2 s . c o m * * @author paouelle * * @see com.github.helenusdriver.driver.impl.ClassInfoImpl#classInfos() */ @Override public Stream<ClassInfoImpl<? extends T>> classInfos() { return Stream.concat(Stream.of(this), ctypes.values().stream()); }
From source file:org.teavm.junit.TeaVMTestRunner.java
private MethodDescriptor getDescriptor(Method method) { ValueType[] signature = Stream.concat(Arrays.stream(method.getParameterTypes()).map(ValueType::parse), Stream.of(ValueType.parse(method.getReturnType()))).toArray(ValueType[]::new); return new MethodDescriptor(method.getName(), signature); }
From source file:com.spankingrpgs.model.characters.GameCharacter.java
/** * Returns the value of all the statistics in the order they were added to the character as an unmodifiable * map.// w ww. ja va 2s. c om * * @return the value of all the statistics in the order they were added to the character. */ @JsonIgnore public Map<String, Integer> getAllStatistics() { LinkedHashMap<String, Integer> allStatistics = new LinkedHashMap<>( primaryStatistics.size() + secondaryStatistics.size()); Stream.concat(primaryStatistics.entrySet().stream(), secondaryStatistics.entrySet().stream()) .forEach(entry -> allStatistics.put(entry.getKey(), entry.getValue())); return Collections.unmodifiableMap(allStatistics); }
From source file:util.ItUtils.java
/** * Concatenates a vararg to a String array. * * Useful when using {@link #runVerboseProjectAnalysis(Orchestrator, String, String...)}, eg.: * <pre>//from w w w .ja v a2 s . c o m * ItUtils.runProjectAnalysis(orchestrator, "project_name", * ItUtils.concat(properties, "sonar.scm.disabled", "false") * ); * </pre> */ public static String[] concat(String[] properties, String... str) { if (properties == null || properties.length == 0) { return str; } return Stream.concat(Arrays.stream(properties), Arrays.stream(str)).toArray(String[]::new); }
From source file:org.sleuthkit.autopsy.timeline.ui.detailview.EventDetailsChart.java
/** * @return all the nodes that pass the given predicate *//*w w w.jav a2s. c om*/ Iterable<EventBundleNodeBase<?, ?, ?>> getNodes(Predicate<EventBundleNodeBase<?, ?, ?>> p) { //use this recursive function to flatten the tree of nodes into an iterable. Function<EventBundleNodeBase<?, ?, ?>, Stream<EventBundleNodeBase<?, ?, ?>>> stripeFlattener = new Function<EventBundleNodeBase<?, ?, ?>, Stream<EventBundleNodeBase<?, ?, ?>>>() { @Override public Stream<EventBundleNodeBase<?, ?, ?>> apply(EventBundleNodeBase<?, ?, ?> node) { return Stream.concat(Stream.of(node), node.getSubNodes().stream().flatMap(this::apply)); } }; return stripeNodeMap.values().stream().flatMap(stripeFlattener).filter(p).collect(Collectors.toList()); }