Example usage for com.google.common.collect Lists transform

List of usage examples for com.google.common.collect Lists transform

Introduction

In this page you can find the example usage for com.google.common.collect Lists transform.

Prototype

@CheckReturnValue
public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function) 

Source Link

Document

Returns a list that applies function to each element of fromList .

Usage

From source file:se.kth.karamel.common.util.CollectionsUtil.java

public static List<String> asStringList(List<Object> list) {
    List<String> newList = Lists.transform(list, new Function<Object, String>() {
        @Override/*from   www  .  j  a  va 2  s .  c  o m*/
        public String apply(Object input) {
            return input.toString();
        }
    });
    return newList;
}

From source file:org.carrot2.cli.batch.BatchApp.java

public static void main(String[] args) throws Exception {
    final BatchApp batch = new BatchApp();

    final CmdLineParser parser = new CmdLineParser(batch);
    parser.setUsageWidth(80);/*from   w  w  w .j a va  2  s. co m*/

    try {
        parser.parseArgument(args);
        System.exit(batch.process());
    } catch (CmdLineException e) {
        System.out.print("Usage: batch");
        parser.printSingleLineUsage(System.out);
        System.out.println();
        parser.printUsage(System.out);

        System.out.println("\n" + e.getMessage());

        final List<String> algorithmIds = Lists.transform(batch.algorithms,
                ProcessingComponentDescriptorToId.INSTANCE);
        System.out.println("\nAvailable algorithms: " + algorithmIds.toString());
    }
}

From source file:net.orfjackal.retrolambda.test.InMainSources.java

public static List<String> useLambdaOfImportedType(List<String> items) {
    return Lists.transform(items, String::toUpperCase);
}

From source file:org.eclipse.recommenders.tests.jayes.util.ArrayUtils.java

public static double[] flatten(double[][][] array) {
    return ArrayFlatten
            .flatten(Lists.transform(Arrays.asList(array), new ArrayFlatten()).toArray(new double[0][]));
}

From source file:com.facebook.buck.cli.BuildTargetNormalizer.java

public static List<String> getArgumentsFormattedAsBuildTargets(List<String> arguments) {
    return Lists.transform(arguments, CommandLineBuildTargetNormalizer.normalize);
}

From source file:org.opendaylight.protocol.util.InetSocketAddressUtil.java

public static List<InetSocketAddress> parseAddresses(final String address, final int defaultPort) {
    return Lists.transform(Arrays.asList(address.split(SEPARATOR)),
            input -> getInetSocketAddress(input, defaultPort));
}

From source file:com.spotify.dns.DnsTestUtil.java

static List<LookupResult> nodes(String... nodeNames) {
    return Lists.transform(Arrays.asList(nodeNames), new Function<String, LookupResult>() {
        @Override//from   w w w  .  j  a v  a2 s.  c  om
        public LookupResult apply(String input) {
            return LookupResult.create(input, 8080, 1, 2, 999);
        }
    });
}

From source file:gt.org.ms.api.global.exceptions.ExceptionsManager.java

public static RuntimeException newValidationException(String cause, String[] errors) {
    return new ValidationException(
            Lists.transform(Arrays.asList(errors), new Function<String, ValidationError>() {
                @Override/*from   w  ww . j  a  v  a2s .  co  m*/
                public ValidationError apply(String f) {
                    return splitError(f);
                }
            }));
}

From source file:com.cloudera.science.ml.client.util.UnionIO.java

public static <T> PCollection<T> from(List<String> paths, Function<String, PCollection<T>> f) {
    PCollection<T> ret = null;//  w w  w .j  a v  a2s  . c om
    for (PCollection<T> p : Lists.transform(paths, f)) {
        if (ret == null) {
            ret = p;
        } else {
            ret = ret.union(p);
        }
    }
    return ret;
}

From source file:dmh.swing.html.constants.ParagraphType.java

/**
 * @return A list of all supported HTML tags.
 *//* ww w .j av  a 2  s  .  co m*/
public static List<HTML.Tag> getTags() {
    return Lists.transform(Arrays.asList(values()), new Function<ParagraphType, HTML.Tag>() {
        @Override
        public Tag apply(ParagraphType input) {
            return input.tag;
        }
    });
}