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:com.switchfly.inputvalidation.sanitizer.UrlStripHtmlSanitizer.java

public static List<NameValuePair> parse(String queryString) {
    List<NameValuePair> result = Collections.emptyList();
    if (queryString != null && queryString.length() > 0) {
        result = new ArrayList<NameValuePair>();
        parse(result, new Scanner(queryString));
    }//from w w w.  ja  va  2 s .c  o  m
    return result;
}

From source file:ddf.security.permission.Permissions.java

public static List<String> getPermissionsAsStrings(Map<String, Set<String>> attributes) {
    if (attributes == null) {
        return Collections.emptyList();
    }/*  w w  w . j a  v  a2  s  .  c om*/
    List<String> stringAttributes = new ArrayList<>(attributes.size());
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<String, Set<String>> entry : attributes.entrySet()) {
        sb.append(entry.getKey());
        sb.append("=");
        sb.append(StringUtils.join(entry.getValue(), ","));
        stringAttributes.add(sb.toString());
        sb.setLength(0);
    }
    return stringAttributes;
}

From source file:com.act.analysis.similarity.SubstructureSearch.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());/*  ww  w  .j ava  2 s.c om*/
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.err.format("Argument parsing failed: %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(SubstructureSearch.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(SubstructureSearch.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        return;
    }

    if (cl.hasOption(OPTION_LICENSE_FILE)) {
        LicenseManager.setLicenseFile(cl.getOptionValue(OPTION_LICENSE_FILE));
    }

    List<String> searchOpts = Collections.emptyList();
    if (cl.hasOption(OPTION_SEARCH_OPTIONS)) {
        searchOpts = Arrays.asList(cl.getOptionValues(OPTION_SEARCH_OPTIONS));
    }

    // Make sure we can initialize correctly before opening any file handles for writing.
    SubstructureSearch matcher = new SubstructureSearch();
    try {
        matcher.init(cl.getOptionValue(OPTION_QUERY), searchOpts);
    } catch (IllegalArgumentException e) {
        System.err.format("Unable to initialize substructure search.  %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(SubstructureSearch.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    } catch (MolFormatException e) {
        System.err.format("Invalid SMILES structure query.  %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(SubstructureSearch.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    Pair<List<String>, Iterator<Map<String, String>>> iterPair = null;
    if (cl.hasOption(OPTION_INPUT_FILE)) {
        File inFile = new File(cl.getOptionValue(OPTION_INPUT_FILE));
        if (!inFile.exists()) {
            System.err.format("File at %s does not exist", inFile.getAbsolutePath());
            HELP_FORMATTER.printHelp(SubstructureSearch.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                    true);
            System.exit(1);
        }
        iterPair = iterateOverTSV(inFile);
    } else if (cl.hasOption(OPTION_INPUT_DB)) {
        iterPair = iterateOverDB(cl.getOptionValue(OPTION_INPUT_DB_HOST, DEFAULT_HOST),
                Integer.parseInt(cl.getOptionValue(OPTION_INPUT_DB_HOST, DEFAULT_PORT)),
                cl.getOptionValue(OPTION_INPUT_DB));
    } else {
        System.err.format("Must specify either input TSV file or input DB from which to read.\n");
        HELP_FORMATTER.printHelp(SubstructureSearch.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    TSVWriter<String, String> writer = new TSVWriter<>(iterPair.getLeft());
    writer.open(new File(cl.getOptionValue(OPTION_OUTPUT_FILE)));

    LOGGER.info("Seaching for substructure '%s'", cl.getOptionValue(OPTION_QUERY));

    try {
        int rowNum = 0;
        while (iterPair.getRight().hasNext()) {
            Map<String, String> row = iterPair.getRight().next();
            rowNum++;
            try {
                String inchi = row.get(FIELD_INCHI);
                Molecule target = null;
                try {
                    target = MolImporter.importMol(inchi);
                } catch (Exception e) {
                    LOGGER.warn("Skipping molecule %d due to exception: %s\n", rowNum, e.getMessage());
                    continue;
                }
                if (matcher.matchSubstructure(target)) {
                    writer.append(row);
                    writer.flush();
                } else {
                    // Don't output if not a match.
                    LOGGER.debug("Found non-matching molecule: %s", inchi);
                }
            } catch (SearchException e) {
                LOGGER.error("Exception on input line %d: %s\n", rowNum, e.getMessage());
                throw e;
            }
        }
    } finally {
        writer.close();
    }
    LOGGER.info("Done with substructure search");
}

From source file:cz.muni.fi.mir.db.dao.impl.AnnotationDAOImpl.java

@Override
public List<Annotation> getAllAnnotations() {
    List<Annotation> resultList = Collections.emptyList();

    try {//from w  ww.  j a  va2  s .  c o  m
        resultList = entityManager
                .createQuery("SELECT a FROM annotation a ORDER BY a.id DESC", Annotation.class).getResultList();
    } catch (NoResultException nre) {
        logger.debug(nre);
    }

    return resultList;
}

From source file:com.gooddata.md.report.ReportDefinitionContentTest.java

@Test
public void testSerialization() throws Exception {
    final ReportDefinitionContent def = new GridReportDefinitionContent(
            new Grid(Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
    assertThat(def, jsonEquals(resource("md/report/gridReportDefinitionContent-input.json")));
}

From source file:ly.stealth.punxsutawney.Marathon.java

public static List<String> getEndpoints(String app) throws IOException {
    @SuppressWarnings("unchecked")
    List<JSONObject> tasks = getTasks(app);
    if (tasks == null)
        return Collections.emptyList();

    List<String> endpoints = new ArrayList<>();
    for (JSONObject task : tasks)
        endpoints.add(task.get("host") + ":" + ((JSONArray) task.get("ports")).get(0));

    return endpoints;
}

From source file:com.gooddata.md.report.OneNumberReportDefinitionContentTest.java

@Test
public void testSerialization() throws Exception {
    final OneNumberReportDefinitionContent def = new OneNumberReportDefinitionContent(
            new Grid(Collections.emptyList(), Collections.emptyList(), Collections.emptyList()), "desc",
            Collections.emptyList());
    assertThat(def, jsonEquals(resource("md/report/oneNumberReportDefinitionContent-input.json")));
}

From source file:org.bonitasoft.web.designer.model.contract.LeafContractInput.java

@Override
public List<ContractInput> getInput() {
    return Collections.emptyList();
}

From source file:cz.muni.fi.mir.db.dao.impl.SourceDocumentDAOImpl.java

@Override
public List<SourceDocument> getAllDocuments() {
    List<SourceDocument> resultList = Collections.emptyList();
    try {//from   w  w  w . j  a va2 s  . c  o m
        resultList = entityManager.createQuery("SELECT sd FROM sourceDocument sd", SourceDocument.class)
                .getResultList();
    } catch (NoResultException nre) {
        logger.debug(nre);
    }

    return resultList;
}

From source file:dlauncher.modpacks.packs.VanillaModPackVersion.java

public VanillaModPackVersion(JSONObject jsonObject, ModPack main) {
    this.main = main;
    this.branch = jsonObject.getString("type");
    this.version = jsonObject.getString("id");
    try {//from w ww .j a va 2s.co  m
        this.releaseDate = dateFormat.parse(jsonObject.getString("releaseTime")).getTime();
    } catch (ParseException ex) {
        throw new Error(ex);
    }
    this.installedSize = -1;
    this.downloads = Collections.emptyList();
}