Example usage for java.util List stream

List of usage examples for java.util List stream

Introduction

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

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:com.netflix.spinnaker.clouddriver.kubernetes.provider.KubernetesModelUtil.java

private static boolean someUpRemainingUnknown(List<Map<String, String>> healthsList) {
    List<Map<String, String>> knownHealthList = healthsList.stream()
            .filter(h -> !stateEquals(h, HealthState.Unknown)).collect(Collectors.toList());

    return !knownHealthList.isEmpty() && knownHealthList.stream().allMatch(h -> stateEquals(h, HealthState.Up));
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.provider.KubernetesModelUtil.java

private static boolean someSucceededRemainingUnknown(List<Map<String, String>> healthsList) {
    List<Map<String, String>> knownHealthList = healthsList.stream()
            .filter(h -> !stateEquals(h, HealthState.Unknown)).collect(Collectors.toList());

    return !knownHealthList.isEmpty()
            && knownHealthList.stream().allMatch(h -> stateEquals(h, HealthState.Succeeded));
}

From source file:com.spotify.scio.extra.transforms.ProcessUtil.java

static List<String[]> tokenizeCommands(List<String> command) {
    if (command == null) {
        return null;
    }/* w  w  w  .  j  a  v a2  s.c  om*/
    return command.stream().map(ProcessUtil::tokenizeCommand).collect(Collectors.toList());
}

From source file:com.fizzed.blaze.internal.DependencyHelper.java

static public Set<String> toGroupArtifactSet(List<Dependency> dependencies) {
    return dependencies.stream().map((d) -> d.getGroupId() + ":" + d.getArtifactId())
            .collect(Collectors.toSet());
}

From source file:Main.java

public static <T> CompletableFuture<T> anyOfFutures(List<? extends CompletableFuture<? extends T>> futures) {
    CompletableFuture<T> cf = new CompletableFuture<>();
    CompletableFuture/*w w  w.  j  a  v  a  2  s  . com*/
            .allOf(futures.stream().map(f -> f.thenAccept(cf::complete)).toArray(CompletableFuture<?>[]::new))
            .exceptionally(ex -> {
                cf.completeExceptionally(ex);
                return null;
            });
    return cf;
}

From source file:com.movies.jsf.JsfUtil.java

public static void addErrorMessages(List<String> messages) {
    messages.stream().forEach((message) -> {
        addErrorMessage(message);//from ww  w  . j  av  a 2 s .  c  o  m
    });
}

From source file:lumbermill.api.AnyJsonEvent.java

public static AnyJsonEvent fromJsonEvents(List<JsonEvent> events) {
    return new AnyJsonEvent(Codecs.objectMapper.createArrayNode()
            .addAll(events.stream().map(jsonEvent -> jsonEvent.jsonNode).collect(toList())));
}

From source file:Main.java

/**
 * Draws Premade list and returns filtered list.
 * //from   w  w w .ja  v a  2s. c  o  m
 * @param <T>
 *            Class for list where you get random item.
 * @param list
 *            Draws data from premade list.
 * @param filter
 *            Represents a boolean from the predicate statement.
 * @return Filtered list.
 */
public static <T> int timesFound(List<T> list, Predicate<T> filter) {
    return (int) list.stream().filter(filter).count();
}

From source file:com.formkiq.core.form.FormTransformer.java

/**
 * Update {@link FormJSON} by the selected 'optionsgroup'.
 * @param form {@link FormJSON}//from  w w  w  . j  ava  2  s .  c om
 */
public static void updateOptionsGroup(final FormJSON form) {

    List<FormJSONField> list = stream(form).collect(Collectors.toList());

    List<String> optionsGroup = list.stream()
            .filter(f -> !CollectionUtils.isEmpty(f.getOptionsgroup())
                    && f.getOptionsgroup().size() == f.getOptions().size()
                    && f.getOptions().indexOf(f.getValue()) != -1)
            .map(f -> f.getOptionsgroup().get(f.getOptions().indexOf(f.getValue())))
            .collect(Collectors.toList());

    list.forEach(f -> {
        f.setHide(ListUtils.intersection(f.getGroups(), optionsGroup).isEmpty());

        if (CollectionUtils.isEmpty(f.getGroups())) {
            f.setHide(false);
        }
    });
}

From source file:io.kodokojo.service.SmtpEmailSender.java

private static InternetAddress[] convertToInternetAddress(List<String> input) {
    List<InternetAddress> res = input.stream().map(addr -> {
        try {//from ww  w. j a v a2 s  .  c  om
            return new InternetAddress(addr);
        } catch (AddressException e) {
            LOGGER.error("Ignoring following address to send mail.'{}'", addr);
            return null;
        }
    }).filter(addr -> addr != null).collect(Collectors.toList());
    return res.toArray(new InternetAddress[res.size()]);
}