Example usage for java.util.stream Stream concat

List of usage examples for java.util.stream Stream concat

Introduction

In this page you can find the example usage for java.util.stream Stream concat.

Prototype

public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b) 

Source Link

Document

Creates a lazily concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream.

Usage

From source file:org.onosproject.store.primitives.impl.DefaultTransactionalMapParticipant.java

@Override
protected Stream<MapUpdate<K, V>> records(Version lockVersion) {
    return Stream.concat(deleteStream(), writeStream(lockVersion));
}

From source file:net.kemitix.checkstyle.ruleset.builder.DefaultRuleReadmeLoader.java

@Override
public Stream<String> load(final Rule rule) {
    if (rule.isEnabled()) {
        final Path resolve = templateProperties.getReadmeFragments().resolve(rule.getName() + ".md");
        log.info("Loading fragment: {}", resolve);
        try {/*from  w w  w. j av a2s  .c  o m*/
            return Stream.concat(Stream.of(formatRuleHeader(rule)), Files.lines(resolve));
        } catch (IOException e) {
            throw new ReadmeFragmentNotFoundException(rule.getName(), e);
        }
    } else {
        return Stream.of(formatRuleHeader(rule), "", rule.getReason());
    }
}

From source file:com.ikanow.aleph2.data_model.utils.ProcessUtils.java

/**
 * Starts the given process by calling process_builder.start();
 * Records the started processes pid and start date.
 *  //w w  w.j av  a 2  s .  c  o  m
 * @param process_builder
 * @throws IOException 
 * @return returns any error in _1(), the pid in _2()
 */
public static Tuple2<String, String> launchProcess(final ProcessBuilder process_builder,
        final String application_name, final DataBucketBean bucket, final String aleph_root_path,
        final Optional<Tuple2<Long, Integer>> timeout_kill) {
    try {
        if (timeout_kill.isPresent()) {
            final Stream<String> timeout_stream = Stream.of("timeout", "-s", timeout_kill.get()._2.toString(),
                    timeout_kill.get()._1.toString());
            process_builder.command(Stream.concat(timeout_stream, process_builder.command().stream())
                    .collect(Collectors.toList()));
        }

        //starts the process, get pid back
        logger.debug("Starting process: " + process_builder.command().toString());
        final Process px = process_builder.start();
        String err = null;
        String pid = null;
        if (!px.isAlive()) {
            err = "Unknown error: " + px.exitValue() + ": "
                    + process_builder.command().stream().collect(Collectors.joining(" "));
            // (since not capturing output)
        } else {
            pid = getPid(px);
            //get the date on the pid file from /proc/<pid>
            final long date = getDateOfPid(pid);
            //record pid=date to aleph_root_path/pid_manager/bucket._id/application_name
            storePid(application_name, bucket, aleph_root_path, pid, date);
        }
        return Tuples._2T(err, pid);

    } catch (Throwable t) {
        return Tuples._2T(ErrorUtils.getLongForm("{0}", t), null);
    }
}

From source file:com.cybernostics.jsp2thymeleaf.api.elements.CopyElementConverter.java

@Override
public List<Content> process(JSPParser.JspElementContext node, JSPElementNodeConverter context) {
    Optional<Element> maybeElement = createElement(node, context);
    if (maybeElement.isPresent()) {
        Element element = maybeElement.get();
        element.removeNamespaceDeclaration(XMLNS);
        element.addContent(getNewChildContent(node, context));
        addAttributes(element, node, context);
        return Stream.concat(Stream.of(element), getNewAppendedContent(node, context).stream())
                .collect(toList());//  ww w.  j a v  a 2s . c o m
    }

    return EMPTY_LIST;
}

From source file:com.github.robozonky.app.events.SessionEvents.java

@SuppressWarnings("unchecked")
static <T extends Event> Class<T> getImplementingEvent(final Class<T> original) {
    final Stream<Class<?>> provided = ClassUtils.getAllInterfaces(original).stream();
    final Stream<Class<?>> interfaces = original.isInterface() ? // interface could be extending it directly
            Stream.concat(Stream.of(original), provided) : provided;
    final String apiPackage = "com.github.robozonky.api.notifications";
    return (Class<T>) interfaces.filter(i -> Objects.equals(i.getPackage().getName(), apiPackage))
            .filter(i -> i.getSimpleName().endsWith("Event"))
            .filter(i -> !Objects.equals(i.getSimpleName(), "Event")).findFirst()
            .orElseThrow(() -> new IllegalStateException("Not an event:" + original));
}

From source file:com.create.security.RepositoryUserDetailsService.java

private List<GrantedAuthority> getGrantedAuthorities(User user) {
    return Stream.concat(getGrantedAuthoritiesForRoles(user), getGrantedAuthoritiesForPermissions(user))
            .collect(Collectors.toList());
}

From source file:de.bund.bfr.math.MultivariateOptimization.java

public static MultivariateOptimization createLodOptimizer(String formula, List<String> parameters,
        List<Double> targetValues, Map<String, List<Double>> variableValues, double levelOfDetection)
        throws ParseException {
    String sdParam = parameters.stream().collect(Collectors.joining());
    List<String> params = Stream.concat(parameters.stream(), Stream.of(sdParam)).collect(Collectors.toList());

    return new MultivariateOptimization(params, sdParam,
            new LodFunction(formula, params, variableValues, targetValues, levelOfDetection, sdParam));
}

From source file:org.sonar.server.qualityprofile.DefinedQProfileRepositoryRule.java

public DefinedQProfileRepositoryRule set(String languageKey, DefinedQProfile first, DefinedQProfile... others) {
    qProfilesbyLanguage.put(languageKey,
            Stream.concat(Stream.of(first), Arrays.stream(others)).collect(toList(1 + others.length)));
    return this;
}

From source file:org.openlmis.fulfillment.service.request.RequestHelper.java

/**
 * Split the given {@link RequestParameters} into smaller chunks.
 *//*from   w w w.  j  ava 2  s  .c  o  m*/
public static URI[] splitRequest(String url, RequestParameters queryParams, int maxUrlLength) {
    RequestParameters safeQueryParams = RequestParameters.init().setAll(queryParams);
    URI uri = createUri(url, safeQueryParams);

    if (uri.toString().length() > maxUrlLength) {
        Pair<RequestParameters, RequestParameters> split = safeQueryParams.split();

        if (null != split.getLeft() && null != split.getRight()) {
            URI[] left = splitRequest(url, split.getLeft(), maxUrlLength);
            URI[] right = splitRequest(url, split.getRight(), maxUrlLength);

            return Stream.concat(Arrays.stream(left), Arrays.stream(right)).distinct().toArray(URI[]::new);
        }
    }

    return new URI[] { uri };
}

From source file:com.yahoo.bard.webservice.druid.model.aggregation.FilteredAggregation.java

@JsonIgnore
@Override// ww  w  . ja v a 2  s .  co m
public Set<Dimension> getDependentDimensions() {
    return Stream.concat(aggregation.getDependentDimensions().stream(), getFilterDimensions().stream())
            .collect(Collectors.toCollection(LinkedHashSet::new));
}