List of usage examples for java.util Collections EMPTY_SET
Set EMPTY_SET
To view the source code for java.util Collections EMPTY_SET.
Click Source Link
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:org.apache.openejb.server.Main.java
public static void main(String args[]) throws SystemExitException { CommandLineParser parser = new PosixParser(); // create the Options Options options = new Options(); options.addOption(option("v", "version", "cmd.start.opt.version")); options.addOption(option("h", "help", "cmd.start.opt.help")); options.addOption(option(null, "conf", "file", "cmd.start.opt.conf")); options.addOption(option(null, "local-copy", "boolean", "cmd.start.opt.localCopy")); options.addOption(option(null, "examples", "cmd.start.opt.examples")); ResourceFinder finder = new ResourceFinder("META-INF/"); Set<String> services = null; try {//from ww w . ja v a 2s . c om Map<String, Properties> serviceEntries = finder.mapAvailableProperties(ServerService.class.getName()); services = serviceEntries.keySet(); for (String service : services) { options.addOption(option(null, service + "-port", "int", "cmd.start.opt.port", service)); options.addOption(option(null, service + "-bind", "host", "cmd.start.opt.bind", service)); } } catch (Exception e) { services = Collections.EMPTY_SET; } CommandLine line = null; try { // parse the command line arguments line = parser.parse(options, args); } catch (ParseException exp) { help(options); throw new SystemExitException(-1); } if (line.hasOption("help")) { help(options); return; } else if (line.hasOption("version")) { OpenEjbVersion.get().print(System.out); return; } else if (line.hasOption("examples")) { try { String text = finder.findString("org.apache.openejb.cli/start.examples"); System.out.println(text); return; } catch (Exception e) { System.err.println("Unable to print examples:"); e.printStackTrace(System.err); throw new SystemExitException(-2); } } Properties props = SystemInstance.get().getProperties(); if (line.hasOption("conf")) { props.setProperty("openejb.configuration", line.getOptionValue("conf")); } else if (line.hasOption("local-copy")) { String value = line.getOptionValue("local-copy"); if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("no") || value.equalsIgnoreCase("off")) { props.setProperty("openejb.localcopy", "false"); } else { props.setProperty("openejb.localcopy", "true"); } } for (String service : services) { String[] opts = { "port", "bind" }; for (String opt : opts) { String option = service + "-" + opt; if (line.hasOption(option)) { props.setProperty(service + "." + opt, line.getOptionValue(option)); } } } try { final SystemInstance system = SystemInstance.get(); File libs = system.getHome().getDirectory("lib"); system.getClassPath().addJarsToPath(libs); initServer(system); } catch (DontStartServerException ignored) { } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.cmu.tetrad.cli.search.FgsCli.java
/** * @param args the command line arguments *///from ww w . j a v a 2s .c o m public static void main(String[] args) { if (args == null || args.length == 0 || Args.hasLongOption(args, "help")) { Args.showHelp("fgs", MAIN_OPTIONS); return; } parseArgs(args); System.out.println("================================================================================"); System.out.printf("FGS Discrete (%s)%n", DateTime.printNow()); System.out.println("================================================================================"); String argInfo = createArgsInfo(); System.out.println(argInfo); LOGGER.info("=== Starting FGS Discrete: " + Args.toString(args, ' ')); LOGGER.info(argInfo.trim().replaceAll("\n", ",").replaceAll(" = ", "=")); Set<String> excludedVariables = (excludedVariableFile == null) ? Collections.EMPTY_SET : getExcludedVariables(); runPreDataValidations(excludedVariables, System.err); DataSet dataSet = readInDataSet(excludedVariables); runOptionalDataValidations(dataSet, System.err); Path outputFile = Paths.get(dirOut.toString(), outputPrefix + ".txt"); try (PrintStream writer = new PrintStream( new BufferedOutputStream(Files.newOutputStream(outputFile, StandardOpenOption.CREATE)))) { String runInfo = createOutputRunInfo(excludedVariables, dataSet); writer.println(runInfo); String[] infos = runInfo.trim().replaceAll("\n\n", ";").split(";"); for (String s : infos) { LOGGER.info(s.trim().replaceAll("\n", ",").replaceAll(":,", ":").replaceAll(" = ", "=")); } Graph graph = runFgs(dataSet, writer); writer.println(); writer.println(graph.toString()); } catch (IOException exception) { LOGGER.error("FGS failed.", exception); System.err.printf("%s: FGS failed.%n", DateTime.printNow()); System.out.println("Please see log file for more information."); System.exit(-128); } System.out.printf("%s: FGS finished! Please see %s for details.%n", DateTime.printNow(), outputFile.getFileName().toString()); LOGGER.info( String.format("FGS finished! Please see %s for details.", outputFile.getFileName().toString())); }
From source file:edu.cmu.tetrad.cli.search.FgsDiscrete.java
/** * @param args the command line arguments *//*ww w. java 2 s.c o m*/ public static void main(String[] args) { if (args == null || args.length == 0 || Args.hasLongOption(args, "help")) { Args.showHelp("fgs-discrete", MAIN_OPTIONS); return; } parseArgs(args); System.out.println("================================================================================"); System.out.printf("FGS Discrete (%s)%n", DateTime.printNow()); System.out.println("================================================================================"); String argInfo = createArgsInfo(); System.out.println(argInfo); LOGGER.info("=== Starting FGS Discrete: " + Args.toString(args, ' ')); LOGGER.info(argInfo.trim().replaceAll("\n", ",").replaceAll(" = ", "=")); Set<String> excludedVariables = (excludedVariableFile == null) ? Collections.EMPTY_SET : getExcludedVariables(); runPreDataValidations(excludedVariables, System.err); DataSet dataSet = readInDataSet(excludedVariables); runOptionalDataValidations(dataSet, System.err); Path outputFile = Paths.get(dirOut.toString(), outputPrefix + ".txt"); try (PrintStream writer = new PrintStream( new BufferedOutputStream(Files.newOutputStream(outputFile, StandardOpenOption.CREATE)))) { String runInfo = createOutputRunInfo(excludedVariables, dataSet); writer.println(runInfo); String[] infos = runInfo.trim().replaceAll("\n\n", ";").split(";"); for (String s : infos) { LOGGER.info(s.trim().replaceAll("\n", ",").replaceAll(":,", ":").replaceAll(" = ", "=")); } Graph graph = runFgsDiscrete(dataSet, writer); writer.println(); writer.println(graph.toString()); if (graphML) { writeOutGraphML(graph, Paths.get(dirOut.toString(), outputPrefix + "_graph.txt")); } } catch (IOException exception) { LOGGER.error("FGS Discrete failed.", exception); System.err.printf("%s: FGS Discrete failed.%n", DateTime.printNow()); System.out.println("Please see log file for more information."); System.exit(-128); } System.out.printf("%s: FGS Discrete finished! Please see %s for details.%n", DateTime.printNow(), outputFile.getFileName().toString()); LOGGER.info(String.format("FGS Discrete finished! Please see %s for details.", outputFile.getFileName().toString())); }
From source file:Main.java
public static Set getMy() { String nullFlag = null;//from w w w . j a v a2 s. c om if (nullFlag == null) { return Collections.EMPTY_SET; } return null; }
From source file:Main.java
/** * byte[] convert to set// w w w . j a va 2 s . c o m */ public static Set<String> byteConvertToSet(byte[] blob, String separate) { if (blob == null) { return null; } if (blob.length == 0) { return Collections.EMPTY_SET; } String sp = TextUtils.isEmpty(separate) ? COMMA : separate; String values = new String(blob); String[] sV = values.split(sp); Set<String> set = new HashSet<>(); for (String v : sV) { set.add(v); } return set; }
From source file:Main.java
/** * string convert to set//ww w . ja v a 2 s. com */ public static Set<String> stringConvertToSet(String values, String separate) { if (values == null) { return null; } if (values.isEmpty()) { return Collections.EMPTY_SET; } String sp = TextUtils.isEmpty(separate) ? COMMA : separate; String[] sV = values.split(sp); Set<String> set = new HashSet<>(); for (String v : sV) { set.add(v); } return set; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> Set<T> emptySet(Class<T> type) { return Collections.EMPTY_SET; }
From source file:Main.java
@SuppressWarnings({ "unchecked" }) public static <E> Set<E> asSet(E... elements) { if (elements == null || elements.length == 0) { return Collections.EMPTY_SET; }/* www.j a v a 2 s. co m*/ LinkedHashSet<E> set = new LinkedHashSet<E>(elements.length * 4 / 3 + 1); Collections.addAll(set, elements); return set; }
From source file:Main.java
/** * Simple method that just returns <code>Collections.EMPTY_SET</code>. * This exists to enable type-safe empty collections so other locations in JSecurity code * do not need to worry about suppressing warnings. * * @param clazz the class of the collection type to return * @return an empty collection//from w w w . j a v a2 s .co m */ @SuppressWarnings({ "unchecked" }) public static <E> Collection<E> emptyCollection(Class<E> clazz) { return Collections.EMPTY_SET; }