Example usage for java.util Collections EMPTY_LIST

List of usage examples for java.util Collections EMPTY_LIST

Introduction

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

Prototype

List EMPTY_LIST

To view the source code for java.util Collections EMPTY_LIST.

Click Source Link

Document

The empty list (immutable).

Usage

From source file:com.adaptris.core.services.jdbc.SimplePayloadResultSetTranslator.java

JdbcResultSet firstResultSet(JdbcResult result) {
    if (result.isHasResultSet()) {
        return result.getResultSet(0);
    }/*from w  ww . j av a  2 s  . c o  m*/
    return new JdbcResultSet() {
        @Override
        public Iterable<JdbcResultRow> getRows() {
            return Collections.EMPTY_LIST;
        }

        @Override
        public void close() {

        }
    };
}

From source file:com.nextep.designer.ui.helpers.UIHelper.java

/**
 * Retrieves the currently selected object model or <code>null</code> if no
 * model selected ./*w  w w.  ja  v a  2s.com*/
 * 
 * @param window
 *            active window or event window
 * @return the model object currently being selected
 */
@SuppressWarnings("unchecked")
public static List<?> getSelectedModel(IWorkbenchWindow window) {
    // Retrieving selection service
    if (window == null || window.getSelectionService() == null) {
        return null;
    }
    ISelection sel = window.getSelectionService().getSelection();
    // We only look for a structured non-empty selection
    if (sel instanceof IStructuredSelection) {
        if (sel != null && !sel.isEmpty()) {
            List<Object> selectedModels = new ArrayList<Object>();
            final IStructuredSelection s = (IStructuredSelection) sel;
            final Iterator<?> selIt = s.iterator();
            while (selIt.hasNext()) {
                selectedModels.add(selIt.next());
            }
            return selectedModels;
        }
    } else {
        IWorkbenchPart part = null;
        final IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            part = page.getActivePart();
        }
        if (part instanceof IEditorPart) {
            final IEditorInput input = ((IEditorPart) part).getEditorInput();
            if (input instanceof IModelOriented<?>) {
                return Arrays.asList(((IModelOriented<?>) input).getModel());
            }
        }

    }
    // Any other context returns a null object
    return Collections.EMPTY_LIST;
}

From source file:com.gargoylesoftware.htmlunit.WebClientWaitForBackgroundJobsTest.java

/**
 * @throws Exception if the test fails/*from   w  ww . jav  a 2 s  .c o m*/
 */
@Test
public void dontWaitWhenUnnecessary() throws Exception {
    final String content = "<html>\n" + "<head>\n" + "  <title>test</title>\n" + "  <script>\n"
            + "    var threadID;\n" + "    function test() {\n"
            + "      threadID = setTimeout(doAlert, 10000);\n" + "    }\n" + "    function doAlert() {\n"
            + "      alert('blah');\n" + "    }\n" + "  </script>\n" + "</head>\n" + "<body onload='test()'>\n"
            + "</body>\n" + "</html>";

    final List<String> collectedAlerts = Collections.synchronizedList(new ArrayList<String>());
    final HtmlPage page = loadPage(content, collectedAlerts);
    final JavaScriptJobManager jobManager = page.getEnclosingWindow().getJobManager();
    assertNotNull(jobManager);
    assertEquals(1, jobManager.getJobCount());

    startTimedTest();
    assertEquals(1, page.getWebClient().waitForBackgroundJavaScriptStartingBefore(7000));
    assertMaxTestRunTime(100);
    assertEquals(1, jobManager.getJobCount());
    assertEquals(Collections.EMPTY_LIST, collectedAlerts);
}

From source file:org.cloudfoundry.runtime.CloudServicesScannerTest.java

/**
 * Verifies that service scan will not throw any Exceptions if the app is
 * missing dependencies such as spring-data-mongo, etc. The
 * missing-deps-test-app uses cloud:service-scan and is actually missing
 * every service dependency (spring-amqp, spring-data, a DataSource), but
 * the app should start successfully as long as there are no services bound
 *
 * @throws IOException//from w ww . ja  v  a 2  s  .  c  o m
 */
@SuppressWarnings("unchecked")
@Test
public void serviceScanMissingDependencies() throws IOException {
    createAndStartApp("cf-runtime-missing-deps-test-app", Collections.EMPTY_LIST);
    assertTrue("Test application is not available",
            testAppCreator.isAppAvailable(computeAppUrl(), 500l, 120000l));
}

From source file:net.mlw.vlh.web.util.JspUtils.java

/**
 * Converts a stirng into a collection of strings.
 * /*from  w  w  w .  j a  v a  2  s  . c  om*/
 * @param value
 *           The string to be parsed.
 * @param token
 *           The token to be used.
 * @return A Collection of String(s).
 */
public static Collection toCollection(String value, String token) {
    if (value == null || value.length() == 0) {
        return Collections.EMPTY_LIST;
    }

    Collection elements = new ArrayList();
    for (StringTokenizer st = new StringTokenizer(value, token); st.hasMoreElements();) {
        elements.add(st.nextToken());
    }

    return elements;
}

From source file:com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerTest.java

/**
 * @throws Exception if the test fails//  w  w  w . ja v  a 2 s .  c  o m
 */
@Test
public void setClearTimeoutUsesManager() throws Exception {
    final String content = "<html>\n" + "<head>\n" + "  <title>test</title>\n" + "  <script>\n"
            + "    var threadID;\n" + "    function test() {\n"
            + "      threadID = setTimeout(doAlert, 10000);\n" + "    }\n" + "    function doAlert() {\n"
            + "      alert('blah');\n" + "    }\n" + "  </script>\n" + "</head>\n" + "<body onload='test()'>\n"
            + "<a onclick='clearTimeout(threadID);' id='clickme'/>\n" + "</body>\n" + "</html>";

    final List<String> collectedAlerts = Collections.synchronizedList(new ArrayList<String>());
    startTimedTest();
    final HtmlPage page = loadPage(content, collectedAlerts);
    final JavaScriptJobManager jobManager = page.getEnclosingWindow().getJobManager();
    assertNotNull(jobManager);
    assertEquals(1, jobManager.getJobCount());
    final HtmlAnchor a = page.getHtmlElementById("clickme");
    a.click();
    jobManager.waitForJobs(7000);
    assertEquals(0, jobManager.getJobCount());
    assertEquals(Collections.EMPTY_LIST, collectedAlerts);
    assertMaxTestRunTime(10000);
}

From source file:com.seitenbau.jenkins.plugins.dynamicparameter.ChoiceParameterDefinitionTest.java

/**
 * Test for {@link ChoiceParameterDefinition#getChoices()}.
 *///from  w  w  w .j  a v a 2  s. c  om
@Test
public final void testGetChoicesNull() {
    choiceParameterDefinition = createChoiceParameterDefinition(
            defaultChoiceParameterBuilder.withScript("null"));
    assertEquals(Collections.EMPTY_LIST, choiceParameterDefinition.getChoices());
}

From source file:io.seldon.general.ItemStorage.java

private List<SqlItemPeer.ItemAndScore> retrieveMostPopularItemsWithScoreImpl(final String key,
        final String client, final int numItems, final int dimension) {

    List<SqlItemPeer.ItemAndScore> retrievedItems = retrieveUsingJSON(key, numItems,
            new UpdateRetriever<List<SqlItemPeer.ItemAndScore>>() {
                @Override/* w  ww.j  a v  a2 s .  co m*/
                public List<SqlItemPeer.ItemAndScore> retrieve() throws Exception {
                    return provider.getItemPersister(client).retrieveMostPopularItems(numItems, dimension);
                }
            }, new TypeReference<List<SqlItemPeer.ItemAndScore>>() {
            }, MOST_POPULAR_EXPIRE_TIME);

    return retrievedItems == null ? Collections.EMPTY_LIST : retrievedItems;
}

From source file:com.kelveden.karma.AbstractStartMojo.java

protected List<String> valueToKarmaArgument(final Integer value, final String argName) {
    if (value == null) {
        return Collections.EMPTY_LIST;
    }//from  w w  w. j  ava2s  . c o m

    return Arrays.asList(argName, String.valueOf(value));
}

From source file:it.unibas.spicy.model.mapping.rewriting.operators.GenerateCoverageMap.java

@SuppressWarnings("unchecked")
private List<Coverage> findCoveragesForTgd(FORule tgd, List<FORule> tgds, MappingTask mappingTask) {
    if (logger.isDebugEnabled())
        logger.debug("----Looking for coverage for: \n" + tgd);
    if (tgd.getTargetView().getVariables().size() == 1) {
        if (logger.isDebugEnabled())
            logger.debug("----TGD has a single target atom, returning empty list ");
        return Collections.EMPTY_LIST;
    }/*from  w  w w  . ja  va 2  s .c  om*/
    List<List<CoverageAtom>> listOfLists = generateCoveringAtomsForTgd(tgd, tgds, mappingTask);
    if (listOfLists == null) {
        return Collections.EMPTY_LIST;
    }
    return generateCoverages(tgd, listOfLists, mappingTask);
}