Example usage for com.google.common.collect ImmutableList of

List of usage examples for com.google.common.collect ImmutableList of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList of.

Prototype

@SuppressWarnings("unchecked")
    public static <E> ImmutableList<E> of() 

Source Link

Usage

From source file:io.prestosql.plugin.thrift.server.ThriftTpchServer.java

public static void main(String[] args) {
    Logger log = Logger.get(ThriftTpchServer.class);
    try {// w  ww .  jav a2s  .com
        start(ImmutableList.of());
        log.info("======== SERVER STARTED ========");
    } catch (Throwable t) {
        log.error(t);
        System.exit(1);
    }
}

From source file:com.facebook.presto.connector.thrift.server.ThriftTpchServer.java

public static void main(String[] args) {
    try {//from w  w  w  .j  av  a  2  s. c  om
        ThriftTpchServer.start(ImmutableList.of());
    } catch (Throwable t) {
        Logger.get(ThriftTpchServer.class).error(t);
        System.exit(1);
    }
}

From source file:com.github.jcustenborder.kafka.connect.spooldir.SchemaGenerator.java

public static void main(String... args) throws Exception {
    ArgumentParser parser = ArgumentParsers.newArgumentParser("CsvSchemaGenerator").defaultHelp(true)
            .description("Generate a schema based on a file.");
    parser.addArgument("-t", "--type").required(true).choices("csv", "json")
            .help("The type of generator to use.");
    parser.addArgument("-c", "--config").type(File.class);
    parser.addArgument("-f", "--file").type(File.class).required(true)
            .help("The data file to generate the schema from.");
    parser.addArgument("-i", "--id").nargs("*").help("Field(s) to use as an identifier.");
    parser.addArgument("-o", "--output").type(File.class)
            .help("Output location to write the configuration to. Stdout is default.");

    Namespace ns = null;// w w  w . j  a v  a 2  s  .c o m

    try {
        ns = parser.parseArgs(args);
    } catch (ArgumentParserException ex) {
        parser.handleError(ex);
        System.exit(1);
    }

    File inputFile = ns.get("file");
    List<String> ids = ns.getList("id");
    if (null == ids) {
        ids = ImmutableList.of();
    }

    Map<String, Object> settings = new LinkedHashMap<>();

    File inputPropertiesFile = ns.get("config");
    if (null != inputPropertiesFile) {
        Properties inputProperties = new Properties();

        try (FileInputStream inputStream = new FileInputStream(inputPropertiesFile)) {
            inputProperties.load(inputStream);
        }
        for (String s : inputProperties.stringPropertyNames()) {
            Object v = inputProperties.getProperty(s);
            settings.put(s, v);
        }
    }

    final SchemaGenerator generator;
    final String type = ns.getString("type");

    if ("csv".equalsIgnoreCase(type)) {
        generator = new CsvSchemaGenerator(settings);
    } else if ("json".equalsIgnoreCase(type)) {
        generator = new JsonSchemaGenerator(settings);
    } else {
        throw new UnsupportedOperationException(
                String.format("'%s' is not a supported schema generator type", type));
    }

    Map.Entry<Schema, Schema> kvp = generator.generate(inputFile, ids);

    Properties properties = new Properties();
    properties.putAll(settings);
    properties.setProperty(SpoolDirSourceConnectorConfig.KEY_SCHEMA_CONF,
            ObjectMapperFactory.INSTANCE.writeValueAsString(kvp.getKey()));
    properties.setProperty(SpoolDirSourceConnectorConfig.VALUE_SCHEMA_CONF,
            ObjectMapperFactory.INSTANCE.writeValueAsString(kvp.getValue()));

    String output = ns.getString("output");
    final String comment = "Configuration was dynamically generated. Please verify before submitting.";

    if (Strings.isNullOrEmpty(output)) {
        properties.store(System.out, comment);
    } else {
        try (FileOutputStream outputStream = new FileOutputStream(output)) {
            properties.store(outputStream, comment);
        }
    }
}

From source file:codetoanalyze.java.checkers.TwoCheckersExample.java

@Expensive
static List shouldRaiseImmutableCastError() {
    return ImmutableList.of();
}

From source file:io.sidecar.util.CollectionUtils.java

public static <T> ImmutableList<T> filterNulls(List<T> orig) {
    if (orig == null) {
        return ImmutableList.of();
    }//from   w  w w  .j  a v a2 s.c  o m
    return ImmutableList.copyOf(Iterables.filter(orig, new Predicate<T>() {
        @Override
        public boolean apply(T t) {
            return t != null;
        }
    }));
}

From source file:com.facebook.buck.util.FakeInvocationInfoFactory.java

public static InvocationInfo create() {
    return InvocationInfo.of(new BuildId(), false, false, "test", ImmutableList.of(), ImmutableList.of(),
            Paths.get(""), false);
}

From source file:com.teradata.benchto.service.utils.CollectionUtils.java

public static <T> List<T> failSafeEmpty(List<T> list) {
    if (list == null) {
        return ImmutableList.of();
    }/*from w ww  .j ava 2s  . c om*/
    return list;
}

From source file:io.prestosql.sql.NodeUtils.java

public static List<SortItem> getSortItemsFromOrderBy(Optional<OrderBy> orderBy) {
    return orderBy.map(OrderBy::getSortItems).orElse(ImmutableList.of());
}

From source file:com.facebook.buck.parser.api.BuildFileManifestFactory.java

public static BuildFileManifest create(ImmutableMap<String, Map<String, Object>> targets) {
    return BuildFileManifest.of(targets, ImmutableSortedSet.of(), ImmutableMap.of(), Optional.empty(),
            ImmutableList.of());
}

From source file:com.google.gerrit.server.patch.MergeListBuilder.java

public static List<RevCommit> build(RevWalk rw, RevCommit merge, int uninterestingParent) throws IOException {
    rw.reset();/* w  ww.  j a  v a 2s . c o m*/
    rw.parseBody(merge);
    if (merge.getParentCount() < 2) {
        return ImmutableList.of();
    }

    for (int parent = 0; parent < merge.getParentCount(); parent++) {
        RevCommit parentCommit = merge.getParent(parent);
        rw.parseBody(parentCommit);
        if (parent == uninterestingParent - 1) {
            rw.markUninteresting(parentCommit);
        } else {
            rw.markStart(parentCommit);
        }
    }

    List<RevCommit> result = new ArrayList<>();
    RevCommit c;
    while ((c = rw.next()) != null) {
        result.add(c);
    }
    return result;
}