Example usage for java.util Collections emptyList

List of usage examples for java.util Collections emptyList

Introduction

In this page you can find the example usage for java.util Collections emptyList.

Prototype

@SuppressWarnings("unchecked")
public static final <T> List<T> emptyList() 

Source Link

Document

Returns an empty list (immutable).

Usage

From source file:Main.java

public static void main(String args[]) {
    List list = Collections.EMPTY_LIST;
    Set set = Collections.EMPTY_SET;
    Map map = Collections.EMPTY_MAP;

    List<String> s = Collections.emptyList();
    Set<Long> l = Collections.emptySet();
    Map<Date, String> d = Collections.emptyMap();
}

From source file:cross.io.PropertyFileGenerator.java

/**
 *
 * @param args/*from  w  ww . j  a  va 2s . c om*/
 */
public static void main(String[] args) {
    Options options = new Options();
    options.addOption("f", true, "base directory for output of files");
    Option provOptions = new Option("p", true,
            "Comma separated list of provider classes to create Properties for");
    provOptions.setRequired(true);
    provOptions.setValueSeparator(',');
    options.addOption(provOptions);
    CommandLineParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    try {
        File basedir = null;
        List<String> providers = Collections.emptyList();
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("f")) {
            basedir = new File(cmd.getOptionValue("f"));
        } else {
            hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options);
        }
        if (cmd.hasOption("p")) {
            String[] str = cmd.getOptionValues("p");
            providers = Arrays.asList(str);
        } else {
            hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options);
        }
        for (String provider : providers) {
            createProperties(provider, basedir);
        }
    } catch (ParseException ex) {
        Logger.getLogger(PropertyFileGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.onebusaway.nyc.vehicle_tracking.utility.SensorModelVerificationMain.java

public static void main(String[] args)
        throws ParseException, ClassNotFoundException, CsvEntityIOException, IOException {

    Options options = new Options();
    options.addOption(ARG_RULE, true, "sensor model rule class");
    GnuParser parser = new GnuParser();
    CommandLine cli = parser.parse(options, args);

    args = cli.getArgs();/*from w  w w  .j  a va  2s  .  co m*/

    if (args.length != 2) {
        System.err.println("usage: data-sources.xml tracesPath");
        System.exit(-1);
    }

    ConfigurableApplicationContext context = ContainerLibrary.createContext(
            "classpath:org/onebusaway/nyc/vehicle_tracking/application-context.xml",
            "classpath:org/onebusaway/transit_data_federation/application-context.xml", args[0]);

    SensorModelVerificationMain m = new SensorModelVerificationMain();
    context.getAutowireCapableBeanFactory().autowireBean(m);

    Collection<SensorModelRule> rules = Collections.emptyList();

    if (cli.hasOption(ARG_RULE)) {
        Class<?> ruleClass = Class.forName(cli.getOptionValue(ARG_RULE));
        rules = Arrays.asList((SensorModelRule) context.getBean(ruleClass));
    } else {
        Map<String, SensorModelRule> rulesByName = context.getBeansOfType(SensorModelRule.class);
        rules = rulesByName.values();
    }

    m.setRules(rules);

    File tracePath = new File(args[1]);
    List<File> traces = new ArrayList<File>();
    getAllTraces(tracePath, traces);
    m.setTraces(traces);

    try {
        m.run();
    } catch (Throwable ex) {
        ex.printStackTrace();
        System.exit(-1);
    }

    System.exit(0);
}

From source file:act.installer.reachablesexplorer.WikiWebServicesExporter.java

public static void main(String[] args) throws Exception {
    CLIUtil cliUtil = new CLIUtil(WikiWebServicesExporter.class, HELP_MESSAGE, OPTION_BUILDERS);
    CommandLine cl = cliUtil.parseCommandLine(args);

    String host = cl.getOptionValue(OPTION_INPUT_DB_HOST, DEFAULT_HOST);
    Integer port = Integer.parseInt(cl.getOptionValue(OPTION_INPUT_DB_PORT, DEFAULT_PORT));
    String dbName = cl.getOptionValue(OPTION_INPUT_DB, DEFAULT_DB);
    String collection = cl.getOptionValue(OPTION_INPUT_DB_COLLECTION, DEFAULT_COLLECTION);
    String sequenceCollection = cl.getOptionValue(OPTION_INPUT_SEQUENCE_COLLECTION,
            DEFAULT_SEQUENCES_COLLECTION);

    LOGGER.info("Attempting to connect to DB %s:%d/%s, collection %s", host, port, dbName, collection);
    Loader loader = new Loader(host, port, UNUSED_SOURCE_DB, dbName, collection, sequenceCollection,
            DEFAULT_RENDERING_CACHE);// w w w.j av  a  2s .  c  o m

    JacksonDBCollection<Reachable, String> reachables = loader.getJacksonReachablesCollection();

    LOGGER.info("Connected to DB, reading reachables");

    List<Long> exportIds = !cl.hasOption(OPTION_EXPORT_SOME) ? Collections.emptyList()
            : Arrays.stream(cl.getOptionValues(OPTION_EXPORT_SOME)).map(Long::valueOf)
                    .collect(Collectors.toList());

    TSVWriter<String, String> tsvWriter = new TSVWriter<>(HEADER);
    tsvWriter.open(new File(cl.getOptionValue(OPTION_OUTPUT_FILE)));
    try {
        DBCursor<Reachable> cursor = exportIds.isEmpty() ? reachables.find()
                : reachables.find(DBQuery.in("_id", exportIds));
        int written = 0;
        while (cursor.hasNext()) {
            final Reachable r = cursor.next();

            Map<String, String> row = new HashMap<String, String>() {
                {
                    put("inchi", r.getInchi());
                    put("inchi_key", r.getInchiKey());
                    put("display_name", r.getPageName());
                    put("image_name", r.getStructureFilename());
                }
            };
            tsvWriter.append(row);
            tsvWriter.flush();
            written++;
        }
        LOGGER.info("Wrote %d reachables to output TSV", written);
    } finally {
        tsvWriter.close();
    }
}

From source file:Main.java

public static final <T> List<T> emptyList() {
    return Collections.emptyList();
}

From source file:Main.java

public static <T> List<T> asList(T... args) {
    if ((args == null) || (args.length == 0)) {
        return Collections.emptyList();
    }/* w  w w .j  av a2s. c  o m*/
    return Arrays.asList(args);
}

From source file:Main.java

@SafeVarargs
public static <T> List<T> list(T... objects) {
    if (objects.length == 0)
        return Collections.emptyList();

    return Arrays.asList(objects);
}

From source file:Main.java

public static <T> List<T> immutableList(Collection<? extends T> list) {
    if (list == null)
        return Collections.emptyList();
    return Collections
            .unmodifiableList(list instanceof List ? (List<? extends T>) list : new ArrayList<T>(list));
}

From source file:Main.java

public static <T> List<T> checkEmptyList(List<T> list) {
    if (list == null) {
        return Collections.emptyList();
    } else {/*from  w  w w  .  java  2  s. com*/
        return list;
    }
}

From source file:Main.java

public static <I> List<I> toList(I... xs) {
    if (isNotEmpty(xs)) {
        return Arrays.asList(xs);
    }//w  w  w .j a v  a  2 s  .c  om
    return Collections.emptyList();
}