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:ws.salient.model.Settings.java

private List<Profile> getProfiles(Collection<String> profileIds) {
    List<Profile> selectedProfiles = new LinkedList();
    Optional.ofNullable(activeProfiles).orElse(Collections.EMPTY_LIST).forEach((id) -> {
        selectedProfiles.add(this.profiles.getOrDefault(id, new Profile()));
    });/* w ww  . j  a  v  a  2 s  .c om*/
    if (profileIds != null && this.profiles != null) {
        profileIds.forEach((id) -> {
            selectedProfiles.add(this.profiles.getOrDefault(id, new Profile()));
        });
    }
    return selectedProfiles;
}

From source file:com.tyro.oss.pact.spring4.pact.model.Pact.java

public List<Interaction> getInteractions() {
    if (interactions != null) {
        return Collections.unmodifiableList(interactions);
    }//from   w w w .  j a  v  a  2  s  .  c o m
    return Collections.EMPTY_LIST;
}

From source file:nl.surfnet.coin.api.oauth.OpenConextOauth1TokenServicesTest.java

private OAuthProviderTokenImpl buildToken() {
    final OAuthProviderTokenImpl token = new OAuthProviderTokenImpl();
    token.setValue("value");
    token.setVerifier("verifier");
    token.setSecret("ssh");
    token.setCallbackUrl("callbackurl");
    token.setConsumerKey("consumerkey");
    SAMLAuthenticationToken userAuthentication = new SAMLAuthenticationToken("", Collections.EMPTY_LIST);
    userAuthentication.setClientMetaData(new JanusClientMetadata());
    token.setUserAuthentication(userAuthentication);
    return token;
}

From source file:architecture.ee.web.community.struts2.action.ajax.MySocialNetworkAction.java

public List<SocialNetwork> getConnectedSocialNetworks() {
    if (getUser().isAnonymous())
        return Collections.EMPTY_LIST;
    return socialNetworkManager.getSocialNetworks(getUser());
}

From source file:se.vgregion.urlservice.services.DefaultUrlServiceService.java

/**
 * {@inheritDoc}//from w w w.ja  va  2  s.  com
 */
@SuppressWarnings("unchecked")
@Transactional
@Override
public Bookmark shorten(URI url, Owner owner) {
    return shorten(url, null, Collections.EMPTY_LIST, owner);
}

From source file:io.undertow.servlet.test.session.ServletSessionCrawlerTestCase.java

@Test
public void testCrawlerSessionUsage() throws IOException, InterruptedException {
    final PathHandler pathHandler = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentInfo builder = new DeploymentInfo()
            .setCrawlerSessionManagerConfig(new CrawlerSessionManagerConfig())
            .setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext")
            .setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war")
            .addListener(new ListenerInfo(SessionCookieConfigListener.class))
            .addServlets(new ServletInfo("servlet", SessionServlet.class).addMapping("/aa/b"));
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();/*from   w w w  .  j a  va 2s .c  o m*/
    try {
        pathHandler.addPrefixPath(builder.getContextPath(), manager.start());
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    DefaultServer.setRootHandler(pathHandler);
    TestHttpClient client = new TestHttpClient();

    client.setCookieStore(new CookieStore() {
        @Override
        public void addCookie(Cookie cookie) {

        }

        @Override
        public List<Cookie> getCookies() {
            return Collections.EMPTY_LIST;
        }

        @Override
        public boolean clearExpired(Date date) {
            return false;
        }

        @Override
        public void clear() {

        }
    });
    try {
        HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/aa/b");
        get.addHeader(Headers.USER_AGENT_STRING,
                "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
        HttpResponse result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        String response = HttpClientUtils.readResponse(result);
        Assert.assertEquals("1", response);

        result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        response = HttpClientUtils.readResponse(result);
        Assert.assertEquals("2", response);

        result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        response = HttpClientUtils.readResponse(result);
        Assert.assertEquals("3", response);

    } finally {
        client.getConnectionManager().shutdown();
    }
}

From source file:net.aksingh.owmjapis.AbstractWeather.java

AbstractWeather(JSONObject jsonObj) {
    super(jsonObj);

    long sec = (jsonObj != null) ? jsonObj.optLong(JSON_DATE_TIME, Long.MIN_VALUE) : Long.MIN_VALUE;
    if (sec != Long.MIN_VALUE) { // converting seconds to Date object
        this.dateTime = new Date(sec * 1000);
    } else {/*from  w w  w. j a  v a  2s.co m*/
        this.dateTime = null;
    }

    JSONArray weatherArray = (jsonObj != null) ? jsonObj.optJSONArray(JSON_WEATHER) : new JSONArray();
    this.weatherList = (weatherArray != null) ? new ArrayList<Weather>(weatherArray.length())
            : Collections.EMPTY_LIST;
    if (weatherArray != null && this.weatherList != Collections.EMPTY_LIST) {
        for (int i = 0; i < weatherArray.length(); i++) {
            JSONObject weatherObj = weatherArray.optJSONObject(i);
            if (weatherObj != null) {
                this.weatherList.add(new Weather(weatherObj));
            }
        }
    }
    this.weatherCount = this.weatherList.size();
}

From source file:com.adobe.acs.commons.data.Spreadsheet.java

public Spreadsheet(boolean convertHeaderNames, InputStream file, String... required) throws IOException {
    delimiters = new HashMap<>();
    this.enableHeaderNameConversion = convertHeaderNames;
    if (required == null || required.length == 0) {
        requiredColumns = Collections.EMPTY_LIST;
    } else {/*from  w ww .j  a v a2s .  c o  m*/
        requiredColumns = Arrays.stream(required).map(this::convertHeaderName).collect(Collectors.toList());
    }
    parseInputFile(file);
}

From source file:org.apigw.authserver.x509.CertifiedClientAuthenticationUserDetailsServiceTest.java

@SuppressWarnings("unchecked")
@Test(expected = UsernameNotFoundException.class)
public void loadUserDetailsThrowsNotFoundException() {
    String subjectDN = "CN=dianne,OU=Spring Security,O=Spring Framework,C=AU";
    String issuerDN = "CN=Spring Security Test CA,OU=Spring Security,O=Spring Framework,L=Glasgow,ST=Scotland,C=GB";
    CertifiedClient client = new CertifiedClient();
    client.setClientId("clientA");
    client.setCertifiedClientRoles(Collections.EMPTY_LIST);

    X509ClientPrincipal principal = new X509ClientPrincipal(subjectDN, issuerDN);
    when(token.getPrincipal()).thenReturn(principal);
    when(token.getName()).thenReturn("clientA");
    when(service.loadClientByX509Cert(issuerDN, subjectDN)).thenThrow(UsernameNotFoundException.class);
    UserDetails user = uut.loadUserDetails(token);
}

From source file:com.googlecode.jtiger.modules.ecside.core.RetrievalUtils.java

/**
 * If the collection variable passed in is in fact a Collection then just
 * return it. If it is a Map then return the Map values.
 * /*ww w  . j  ava 2  s.com*/
 * If it is a String then look in the specified servlet scope for the
 * Collection. If the scope is null look through the scopes in order (page,
 * request, session, and application).
 * 
 * If the collection variable is specified with a dot (.) notation then will
 * look for a nested collection. For example foo.values will first look for
 * an object called foo in the various servlet scopes (as described above).
 * Once it finds it then it will look for an attribute called values, which
 * is assumed to be a Collection.
 * 
 * @param collection Either a String or Object that will represent the Collection.
 * @return A Collection.
 */
public static Collection retrieveCollection(WebContext context, Object collection, String scope)
        throws Exception {
    if (collection instanceof Collection) {
        return (Collection) collection;
    } else if (collection instanceof Map) {
        return ((Map) collection).values();
    } else if (collection instanceof String) {
        return retrieveCollectionFromScope(context, String.valueOf(collection), scope);
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("Could not find the Collection.");
        }
        return Collections.EMPTY_LIST;
    }
}