Example usage for java.util Collections singletonList

List of usage examples for java.util Collections singletonList

Introduction

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

Prototype

public static <T> List<T> singletonList(T o) 

Source Link

Document

Returns an immutable list containing only the specified object.

Usage

From source file:com.orange.cepheus.mockorion.AdminController.java

@RequestMapping(value = "/query", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity query(@Valid @RequestBody final Query query)
        throws ExecutionException, InterruptedException {

    QueryContext queryContext = new QueryContext(
            Collections.singletonList(new EntityId(query.getName(), query.getType(), query.getIsPattern())));
    QueryContextResponse queryContextResponse = ngsiClient.queryContext(cepheusBroker, null, queryContext)
            .get();/*from www  .  jav  a  2 s.c o m*/
    logger.info("=> QueryContextResponse received from {}: {}", cepheusBroker, queryContextResponse.toString());
    if (queryContextResponse.getErrorCode() == null) {
        queryContextResponse.getContextElementResponses().forEach(contextElementResponse -> {
            logger.info("EntityId : {}", contextElementResponse.getContextElement().getEntityId().toString());
            contextElementResponse.getContextElement().getContextAttributeList().forEach(contextAttribute -> {
                logger.info("Attribute : {}", contextAttribute.toString());
            });
        });
    }

    return new ResponseEntity<>(HttpStatus.OK);
}

From source file:org.openmrs.module.personalhr.web.taglib.GlobalPropertyTag.java

@Override
public int doStartTag() {
    this.log.debug("Entering GlobalPropertyTag.doStartTag");
    try {/*from  w  ww .j  a  va  2s  . c  o m*/
        //Add temporary privilege
        //PersonalhrUtil.addTemporaryPrivileges();

        Object value;
        if (StringUtils.hasText(this.listSeparator)) {
            value = Collections.singletonList(this.defaultValue);
        } else {
            value = this.defaultValue;
        }

        // If user is logged in
        if (Context.isAuthenticated()) {
            if (StringUtils.hasText(this.listSeparator)) {
                final String stringVal = Context.getAdministrationService().getGlobalProperty(this.key,
                        this.defaultValue);
                if (stringVal.trim().length() == 0) {
                    value = Collections.emptyList();
                } else {
                    value = Arrays.asList(stringVal.split(this.listSeparator));
                }
            } else {
                value = Context.getAdministrationService().getGlobalProperty(this.key, this.defaultValue);
            }
        }

        try {
            if (this.var != null) {
                this.pageContext.setAttribute(this.var, value);
            } else {
                this.pageContext.getOut().write(value.toString());
            }

        } catch (final Exception e) {
            this.log.error("error getting global property", e);
        }
    } finally {
        //PersonalhrUtil.removeTemporaryPrivileges();
    }
    return SKIP_BODY;
}

From source file:io.spring.springoverflow.service.SpringOverflowUserDetailsService.java

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    User user = userRepository.findByDisplayName(username);

    if (user != null) {
        return new org.springframework.security.core.userdetails.User(username, "password",
                Collections.singletonList(new SimpleGrantedAuthority("ROLE_AUTHENTICATED")));
    } else {/*  w  ww  .jav a2 s. com*/
        throw new UsernameNotFoundException("Unable to find " + username);
    }
}

From source file:ch.cyberduck.core.preferences.MemoryPreferences.java

@Override
public List<String> applicationLocales() {
    return Collections.singletonList("en");
}

From source file:io.fluo.core.impl.AppConfigIT.java

@Override
protected List<ObserverConfiguration> getObservers() {
    return Collections.singletonList(new ObserverConfiguration(TestObserver.class.getName()));
}

From source file:com.netflix.spinnaker.echo.pipelinetriggers.eventhandlers.DockerEventHandler.java

private static List<Artifact> getArtifacts(DockerEvent dockerEvent) {
    DockerEvent.Content content = dockerEvent.getContent();

    String name = content.getRegistry() + "/" + content.getRepository();
    String reference = name + ":" + content.getTag();
    return Collections.singletonList(Artifact.builder().type("docker/image").name(name)
            .version(content.getTag()).reference(reference).build());
}

From source file:eu.over9000.cathode.data.parameters.Direction.java

@Override
public List<NameValuePair> buildParamPairs() {
    if (direction == null) {
        return Collections.emptyList();
    }/*  w  ww.j  a v a 2 s  .c  o  m*/
    return Collections.singletonList(new BasicNameValuePair("direction", direction.name()));
}

From source file:ca.uhn.fhir.rest.method.QueryParameterTypeBinder.java

@SuppressWarnings("unchecked")
@Override/*  www. ja va  2s. co  m*/
public List<IQueryParameterOr<?>> encode(FhirContext theContext, IQueryParameterType theValue)
        throws InternalErrorException {
    IQueryParameterType param = theValue;
    List<?> retVal = Collections.singletonList(MethodUtil.singleton(param, null));
    return (List<IQueryParameterOr<?>>) retVal;
}

From source file:devbury.dewey.hipchat.UserManagerTest.java

@Test
public void testFinders() {
    UserEntries userEntries = new UserEntries();
    UserEntry userEntry = new UserEntry();
    userEntry.setId("1");
    userEntry.setName("name");
    userEntry.setMentionName("mentionName");
    userEntries.setUserEntries(Collections.singletonList(userEntry));

    UserInfo userInfo = new UserInfo();
    userInfo.setMentionName("mentionName");
    userInfo.setName("name");
    userInfo.setEmail("email@example.com");
    userInfo.setId("1");
    userInfo.setPhotoUrl("http://photos.example.com/photo.jpg");
    userInfo.setTimezone("timezone");
    userInfo.setTitle("title");
    userInfo.setXmppJid("xmppjid");

    new NonStrictExpectations() {
        {//from   w  ww  .jav a2s  .  co  m
            api.findUserEntries();
            result = userEntries;

            api.findById("1");
            result = userInfo;

            api.findByEmail("email@example.com");
            result = userInfo;
        }
    };

    userManager.configureCaches();

    assertEquals("xmppjid", userManager.findXmppJidById("1"));
    assertEquals("name", userManager.findUserEntryById("1").getName());
    assertEquals("1", userManager.findUserEntryByName("name").getId());
    assertEquals("name", userManager.findUserEntryByMentionName("@mentionName").getName());
    assertEquals("name", userManager.findUserInfoByEmail("email@example.com").getName());
    assertEquals("@mentionName", userManager.findUserInfoById("1").getMentionName());
    assertEquals("1", userManager.findUserInfoByName("name").getId());
    assertEquals("email@example.com", userManager.findUserInfoByMentionName("@mentionName").getEmail());
}

From source file:com.netflix.spinnaker.kork.dynomite.LocalRedisDynomiteClient.java

public LocalRedisDynomiteClient(int port) {
    String rack = StringUtils.isBlank(System.getenv("EC2_REGION")) ? "local" : System.getenv("EC2_REGION");
    HostSupplier localHostSupplier = new HostSupplier() {
        final Host hostSupplierHost = new Host("localhost", rack, Host.Status.Up);

        @Override//from w  w  w  .j av a2 s . c o  m
        public List<Host> getHosts() {
            return Collections.singletonList(hostSupplierHost);
        }
    };

    TokenMapSupplier tokenMapSupplier = new TokenMapSupplier() {
        final Host tokenHost = new Host("localhost", port, rack, Host.Status.Up);
        final HostToken localHostToken = new HostToken(100000L, tokenHost);

        @Override
        public List<HostToken> getTokens(Set<Host> activeHosts) {
            return Collections.singletonList(localHostToken);
        }

        @Override
        public HostToken getTokenForHost(Host host, Set<Host> activeHosts) {
            return localHostToken;
        }
    };

    this.dynoJedisClient = new DynoJedisClient.Builder().withDynomiteClusterName("local")
            .withApplicationName(String.valueOf(port)).withHostSupplier(localHostSupplier)
            .withCPConfig(new ConnectionPoolConfigurationImpl(String.valueOf(port))
                    .setCompressionStrategy(ConnectionPoolConfiguration.CompressionStrategy.NONE)
                    .setLocalRack(rack).withHashtag("{}").withHostSupplier(localHostSupplier)
                    .withTokenSupplier(tokenMapSupplier))
            .build();
}