Example usage for java.util.stream Collectors toList

List of usage examples for java.util.stream Collectors toList

Introduction

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

Prototype

public static <T> Collector<T, ?, List<T>> toList() 

Source Link

Document

Returns a Collector that accumulates the input elements into a new List .

Usage

From source file:com.eventsourcing.hlc.NTPServerTimeProviderTest.java

@DataProvider(name = "delays", parallel = true)
public static Iterator<Object[]> delays() {
    return IntStream.generate(() -> new Random().nextInt(3000))
            .limit(ForkJoinPool.getCommonPoolParallelism() * 10).boxed().map(i -> new Object[] { i })
            .collect(Collectors.toList()).iterator();
}

From source file:eu.itesla_project.commons.tools.Main.java

private static void printUsage() {
    StringBuilder usage = new StringBuilder();
    usage.append("usage: " + TOOL_NAME + " COMMAND [ARGS]\n\nAvailable commands are:\n\n");

    List<Tool> allTools = Lists.newArrayList(ServiceLoader.load(Tool.class)).stream()
            .filter(t -> !t.getCommand().isHidden()).collect(Collectors.toList());

    // group commands by theme
    Multimap<String, Tool> toolsByTheme = Multimaps.index(allTools, new Function<Tool, String>() {
        @Override/*ww  w  .j  a  v a2 s .c o m*/
        public String apply(Tool tool) {
            return tool.getCommand().getTheme();
        }
    });

    for (Map.Entry<String, Collection<Tool>> entry : toolsByTheme.asMap().entrySet()) {
        String theme = entry.getKey();
        List<Tool> tools = new ArrayList<>(entry.getValue());
        Collections.sort(tools, new Comparator<Tool>() {
            @Override
            public int compare(Tool t1, Tool t2) {
                return t1.getCommand().getName().compareTo(t2.getCommand().getName());
            }
        });
        usage.append(theme != null ? theme : "Others").append(":\n");
        for (Tool tool : tools) {
            usage.append(String.format("   %-40s %s", tool.getCommand().getName(),
                    tool.getCommand().getDescription())).append("\n");
        }
        usage.append("\n");
    }

    System.err.print(usage);
    System.exit(1);
}

From source file:com.github.xdcrafts.flower.spring.impl.MiddlewareDefinition.java

private static List<String> split(String string) {
    return Arrays.stream(string.split(SPLITTER_REGEX)).map(String::trim).collect(Collectors.toList());
}

From source file:io.sqp.core.messages.RowDataMessage.java

public static RowDataMessage fromTypedData(List<SqpValue> data) {
    // use json format values instead of SqpValue objects itself!
    return new RowDataMessage(data.stream().map(d -> d.getJsonFormatValue()).collect(Collectors.toList()));
}

From source file:com.blackducksoftware.integration.hub.detect.util.EnumUtilExtension.java

public static <T extends Enum<T>> List<T> parseCommaDelimitted(String commaDelimitedEnumString,
        Class<T> enumClass) {
    return Arrays.stream(commaDelimitedEnumString.split(",")).map(String::trim).filter(StringUtils::isNotBlank)
            .map(token -> Enum.valueOf(enumClass, token)).collect(Collectors.toList());
}

From source file:com.github.blindpirate.gogradle.core.cache.DirectorySnapshot.java

private static String md5(File projectRoot, File targetDir) {
    List<File> allFilesInDir = IOUtils.listAllDescendents(targetDir).stream().sorted(File::compareTo)
            .collect(Collectors.toList());
    StringBuilder sb = new StringBuilder();
    allFilesInDir.forEach(file -> {// w  ww.  java2  s. com
        Path relativePath = projectRoot.toPath().relativize(file.toPath());
        sb.append(file.isFile() ? "f" : "d").append(File.pathSeparatorChar).append(toUnixString(relativePath))
                .append(File.pathSeparatorChar).append(file.length()).append(File.pathSeparatorChar)
                .append(file.lastModified()).append(File.pathSeparatorChar);
    });
    return DigestUtils.md5Hex(sb.toString());
}

From source file:com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NifiFeedProcessorStatsTransform.java

/**
 * Converts the domain model objects to the rest model equivalent
 *
 * @param domains A list of domain objects
 * @return a list of converted objects, or null if the provided list was empty
 *///from   www.j a  v  a2s . com
public static List<NifiFeedProcessorStats> toModel(
        List<? extends com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats> domains) {
    if (domains != null && !domains.isEmpty()) {
        return domains.stream().map(domain -> toModel(domain)).collect(Collectors.toList());
    }
    return null;
}

From source file:com.dickthedeployer.dick.web.mapper.BuildMapper.java

public static BuildModel mapBuild(Build build) {
    Map<String, Build.Status> buildStatusMap = getBuildStatusMap(build);

    return BuildModel.builder().creationDate(build.getCreationDate()).id(build.getId())
            .currentStage(build.getCurrentStage()).lastMessage(build.getLastMessage())
            .stages(build/* w  w w . j  a va  2  s .  com*/
                    .getStages().stream().map(stageName -> StageModel.builder()
                            .status(buildStatusMap.get(stageName)).name(stageName).build())
                    .collect(Collectors.toList()))
            .status(build.getStatus()).build();
}

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

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

From source file:io.github.retz.scheduler.Applications.java

public static List<String> volumes(String role) {
    return (DICTIONARY.entrySet().stream().map(entry -> entry.getValue().toVolumeId(role))
            .collect(Collectors.toList()));
}