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:co.cask.cdap.gateway.router.AuthServerAnnounceTest.java

@Test
public void testEmptyAnnounceAddressConfig() throws Exception {
    HttpRouterService routerService = createRouterService(null);
    routerService.startUp();//from   w ww.ja  va 2  s  .  co m
    try {
        DefaultHttpClient client = new DefaultHttpClient();
        String url = resolveURI(Constants.Router.GATEWAY_DISCOVERY_NAME, "/v3/apps", routerService);
        HttpGet get = new HttpGet(url);
        HttpResponse response = client.execute(get);
        Map<String, List<String>> responseMap = GSON
                .fromJson(new InputStreamReader(response.getEntity().getContent()), TYPE);
        Assert.assertEquals(Collections.EMPTY_LIST, responseMap.get("auth_uri"));
    } finally {
        routerService.shutDown();
    }
}

From source file:com.example.data.PetData.java

public List<Map<String, Object>> findPetByStatus(String status) throws SQLException {
    QueryRunner run = new QueryRunner(H2DB.getDataSource());
    String[] statues = status.split(",");
    String statusInStr = StringUtils.join(
            Arrays.asList(statues).stream().map(s -> "'" + s.trim() + "'").collect(Collectors.toList()), ",");

    if (statues.length > 0) {
        return run
                .query("select * from pet where status in (" + statusInStr + ")",
                        H2DB.mkResultSetHandler("id", "name", "categoryId", "photoUrls", "tags", "status"))
                .stream().map(m -> {//from   w ww  .j ava2 s  . com
                    m.put("photoUrls", H2DB.strToList((String) m.get("photoUrls")));
                    m.put("tags", H2DB.strToList((String) m.get("tags")));
                    m.put("category", getCategory(run, (Long) m.get("categoryId")));
                    m.remove("categoryId");
                    return m;
                }).collect(Collectors.toList());
    }
    return Collections.EMPTY_LIST;
}

From source file:com.frostwire.search.CrawlPagedWebSearchPerformer.java

@Override
public void crawl(CrawlableSearchResult sr) {
    if (numCrawls > 0) {
        numCrawls--;// w  w  w .  ja v a2s .  com

        T obj = cast(sr);
        if (obj != null) {

            String url = getCrawlUrl(obj);

            byte[] failed = cacheGet("failed:" + url);
            if (failed != null) {
                long failedWhen = array2long(failed);
                if ((System.currentTimeMillis() - failedWhen) < FAILED_CRAWL_URL_CACHE_LIFETIME) {
                    //if the failed request is still fresh we stop
                    LOG.info("CrawlPagedWebSearchPerformer::crawl() - hit failed cache url");
                    onResults(Collections.EMPTY_LIST);
                    return;
                } else {
                    cacheRemove("failed:" + url);
                }
            }

            if (url != null) {
                byte[] data = cacheGet(url);

                if (sr instanceof TorrentSearchResult) {
                    String infohash = ((TorrentSearchResult) sr).getHash();
                    if (data == null) {
                        // maybe we've already cached it by infohash (happens quite a bit)
                        data = cacheGet(infohash);
                    } else {
                        cachePut(infohash, data);
                    }
                }

                if (data == null) { // not a big deal about synchronization here
                    LOG.debug("Downloading data for: " + url);

                    if (url.startsWith("magnet")) {
                        data = fetchMagnet(url);
                    } else {
                        data = fetchBytes(url, sr.getDetailsUrl(), DEFAULT_CRAWL_TIMEOUT);
                    }

                    //we put this here optimistically hoping this is actually
                    //valid data. if no data can be crawled from this we remove it
                    //from the cache. we do this because this same data may come
                    //from another search engine and this way we avoid the
                    //expense of performing another download.
                    if (data != null) {
                        cachePut(url, data);

                        if (sr instanceof TorrentSearchResult) {
                            // if the search result has an infohash we can use...
                            String infohash = ((TorrentSearchResult) sr).getHash();
                            cachePut(infohash, data);
                        }
                    } else {
                        LOG.warn("Failed to download data: " + url);
                        cachePut("failed:" + url, long2array(System.currentTimeMillis()));
                    }
                }

                try {
                    if (data != null) {
                        List<? extends SearchResult> results = crawlResult(obj, data);
                        if (results != null) {
                            onResults(results);
                        }
                    }
                } catch (Throwable e) {
                    LOG.warn("Error creating crawled results from downloaded data: " + e.getMessage(), e);
                    cacheRemove(url); // invalidating cache data
                }
            } else {
                try {
                    List<? extends SearchResult> results = crawlResult(obj, null);
                    if (results != null) {
                        onResults(results);
                    }
                } catch (Throwable e) {
                    LOG.warn("Error creating crawled results from search result alone: " + obj.getDetailsUrl()
                            + ", e=" + e.getMessage());//,e);
                }
            }
        }
    }
}

From source file:ch.astina.hesperid.web.components.security.IfRole.java

@SuppressWarnings("unchecked")
private Collection getPrincipalAuthorities() {
    Authentication currentUser = null;//w  w  w  .  j a  v  a2 s .c o  m
    currentUser = SecurityContextHolder.getContext().getAuthentication();

    if (null == currentUser) {
        return Collections.EMPTY_LIST;
    }

    if ((null == currentUser.getAuthorities()) || (currentUser.getAuthorities().size() < 1)) {
        return Collections.EMPTY_LIST;
    }

    Collection granted = Arrays.asList(currentUser.getAuthorities());
    return granted;
}

From source file:com.splicemachine.derby.stream.function.merge.AbstractMergeJoinFlatMapFunction.java

@Override
public Iterator<LocatedRow> call(Iterator<LocatedRow> locatedRows) throws Exception {
    PeekingIterator<LocatedRow> leftPeekingIterator = Iterators.peekingIterator(locatedRows);
    if (!initialized) {
        joinOperation = getOperation();/*from w ww  .  ja  v a 2  s.c om*/
        initialized = true;
        if (!leftPeekingIterator.hasNext())
            return Collections.EMPTY_LIST.iterator();
        initRightScan(leftPeekingIterator);
    }
    final SpliceOperation rightSide = joinOperation.getRightOperation();
    DataSetProcessor dsp = EngineDriver.driver().processorFactory()
            .bulkProcessor(getOperation().getActivation(), rightSide);
    final Iterator<LocatedRow> rightIterator = Iterators.transform(rightSide.getDataSet(dsp).toLocalIterator(),
            new Function<LocatedRow, LocatedRow>() {
                @Override
                public LocatedRow apply(@Nullable LocatedRow locatedRow) {
                    operationContext.recordJoinedRight();
                    return locatedRow;
                }
            });
    ((BaseActivation) joinOperation.getActivation()).setScanStartOverride(null); // reset to null to avoid any side effects
    ((BaseActivation) joinOperation.getActivation()).setScanKeys(null);
    ((BaseActivation) joinOperation.getActivation()).setScanStopOverride(null);
    AbstractMergeJoinIterator iterator = createMergeJoinIterator(leftPeekingIterator,
            Iterators.peekingIterator(rightIterator), joinOperation.getLeftHashKeys(),
            joinOperation.getRightHashKeys(), joinOperation, operationContext);
    iterator.registerCloseable(new Closeable() {
        @Override
        public void close() throws IOException {
            try {
                rightSide.close();
            } catch (StandardException e) {
                throw new RuntimeException(e);
            }
        }
    });
    return iterator;
}

From source file:py.una.pol.karaku.replication.client.ReplicationResponseHandler.java

/**
 * @param response/*from   w  w w.  j a  va 2  s  .  c  o  m*/
 * @return
 */
@SuppressWarnings("rawtypes")
private Collection getItems(Object response) {

    Object respuesta = notNull(response, "Cant get changes from null response");
    Class<?> clazz = notNull(respuesta.getClass());
    Field f = KarakuReflectionUtils.findField(clazz, CHANGE_FIELDS);

    if (f == null) {
        f = ReflectionUtils.findField(response.getClass(), null, List.class);
    }

    notNull(f,
            "Cant get the id field, " + "use the @ReplicationData annotation or create "
                    + "a field with name %s, please see %s",
            Arrays.toString(CHANGE_FIELDS), response.getClass().getName());
    f.setAccessible(true);
    Collection c = (Collection) ReflectionUtils.getField(f, response);

    if (c == null) {
        return Collections.EMPTY_LIST;
    }
    return c;
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

/**
 * @throws Exception if the test fails//from   ww  w  . ja v  a 2 s  .c  om
 */
@Test
public void click_onClickHandler() throws Exception {
    final String firstContent = "<html><head><title>First</title></head><body>\n"
            + "<a href='http://www.foo1.com' id='a1'>link to foo1</a>\n" + "<a href='" + URL_SECOND
            + "' id='a2' " + "onClick='alert(\"clicked\")'>link to foo2</a>\n"
            + "<a href='http://www.foo3.com' id='a3'>link to foo3</a>\n" + "</body></html>";
    final String secondContent = "<html><head><title>Second</title></head><body></body></html>";

    final WebClient client = getWebClient();
    final List<String> collectedAlerts = new ArrayList<>();
    client.setAlertHandler(new CollectingAlertHandler(collectedAlerts));

    final MockWebConnection webConnection = new MockWebConnection();
    webConnection.setResponse(URL_FIRST, firstContent);
    webConnection.setResponse(URL_SECOND, secondContent);
    client.setWebConnection(webConnection);

    final HtmlPage page = client.getPage(URL_FIRST);
    final HtmlAnchor anchor = page.getHtmlElementById("a2");

    assertEquals(Collections.EMPTY_LIST, collectedAlerts);

    final HtmlPage secondPage = anchor.click();

    assertEquals(new String[] { "clicked" }, collectedAlerts);
    assertEquals("Second", secondPage.getTitleText());
}

From source file:de.contentreich.alfresco.webscripts.SpringBeansWebScript.java

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
    String beanPath = req.getServiceMatch().getTemplateVars().get("bean_path");
    String[] path = null;/*w  ww  .  j  av a  2  s  .c  o  m*/
    logger.debug("executeImpl - bean_path = " + beanPath);
    if (beanPath != null && beanPath != "/") {
        path = springBeansHelper.unscapeBeanName(beanPath).split("/");
    }
    Map<String, Object> model = new HashMap<String, Object>();
    Object bean = springBeansHelper.getBean(path);
    if (bean != null) {
        String beanName = (path != null) ? path[path.length - 1] : "";
        model.put("bean_name", beanName);
        if (bean instanceof ApplicationContext) {
            List<String[]> beanDescs = springBeansHelper.getSpringBeans((ApplicationContext) bean, beanName);
            model.put("beans", beanDescs);
            model.put("beans_helper", springBeansHelper);
        } else {
            // No prototypes and no abstract beans and no application contexts !
            String beanClass = bean.getClass().getName();
            model.put("bean_class", beanClass);
            model.put("bean_methods", springBeansHelper.getPublicMethodSignatures(beanClass));
        }
    }
    model.put("path_helper", pathHelper);
    model.put("path", path == null ? Collections.EMPTY_LIST : Arrays.asList(path));
    return model;

}

From source file:io.stallion.plugins.StallionJavaPlugin.java

/**
 * Get a list of available actions//from  ww  w .java  2 s  .c o m
 *
 * @return
 */
public List<? extends StallionRunAction> getActions() {
    return Collections.EMPTY_LIST;
}

From source file:hudson.bugs.JnlpAccessWithSecuredHudsonTest.java

/**
 * Creates a new slave that needs to be launched via JNLP.
 *//*from   w  w w .  ja va  2  s .c  o  m*/
protected Slave createNewJnlpSlave(String name) throws Exception {
    return new DumbSlave(name, "", System.getProperty("java.io.tmpdir") + '/' + name, "2", Mode.NORMAL, "",
            new JNLPLauncher(true), RetentionStrategy.INSTANCE, Collections.EMPTY_LIST);
}