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.acme.legacy.app.manager.FederatedUserConverter.java

@Override
public FederatedUserModel convert(User source) {
    if (source == null)
        return null;

    FederatedUserModel model = new FederatedUserModel();
    Map<String, List<String>> attributes = new HashMap<>();

    model.setAttributes(attributes);/*from  w w  w  .jav a 2 s  .  c o  m*/

    model.setUsername(source.getEmail());
    model.setEmail(source.getEmail());
    model.setFirstName(source.getFirstName());
    model.setLastName(source.getLastName());

    model.setEnabled(source.isEnabled());
    model.setEmailVerified(source.isEmailVerified());

    // map other data to attributes
    attributes.put("title", Collections.singletonList(source.getTitle()));

    // map roles
    model.setRoles(source.getRoles());

    return model;
}

From source file:com.foilen.smalltools.restapi.spring.MvcJsonSpringConfig.java

@Bean
public ViewResolver contentNegotiatingViewResolver(ContentNegotiationManager contentNegotiationManager) {
    ContentNegotiatingViewResolver contentNegotiatingViewResolver = new ContentNegotiatingViewResolver();
    contentNegotiatingViewResolver.setContentNegotiationManager(contentNegotiationManager);
    contentNegotiatingViewResolver.setDefaultViews(Collections.singletonList(mappingJackson2JsonView()));
    return contentNegotiatingViewResolver;
}

From source file:com.joseph.california.test.restapi.PersonRestControllerTest.java

private HttpEntity<?> getHttpEntity() {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.setAccept(Collections.singletonList(new MediaType("application", "json")));
    HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    return requestEntity;
}

From source file:com.arpnetworking.tsdcore.sinks.FileSinkTest.java

@Test
public void testRecordProcessedAggregateData() throws IOException {
    final AggregatedData datum = TestBeanFactory.createAggregatedData();
    final List<AggregatedData> data = Collections.singletonList(datum);
    final Sink fileSink = _fileSinkBuilder.build();
    fileSink.recordAggregateData(data);//from   ww w . j a  va  2  s.c  o  m
    fileSink.close();

    final List<String> outLines = Files.readLines(_outFile, Charsets.UTF_8);
    Assert.assertEquals(1, outLines.size());
    final JsonNode jsonNode = OBJECT_MAPPER.readTree(Iterables.getOnlyElement(outLines));
    Assert.assertEquals(datum.getValue().getValue(), jsonNode.get("value").asDouble(), 0.001);
    Assert.assertEquals(datum.getFQDSN().getMetric(), jsonNode.get("metric").asText());
    Assert.assertEquals(datum.getFQDSN().getService(), jsonNode.get("service").asText());
    Assert.assertEquals(datum.getHost(), jsonNode.get("host").asText());
    Assert.assertEquals(datum.getPeriod(), Period.parse(jsonNode.get("period").asText()));
    Assert.assertEquals(datum.getPeriodStart().getMillis(),
            DateTime.parse(jsonNode.get("periodStart").asText()).getMillis());
    Assert.assertEquals(datum.getFQDSN().getStatistic().getName(), jsonNode.get("statistic").asText());
}

From source file:com.evrythng.thng.resource.model.exception.ErrorMessage.java

/**
 * Creates a new ErrorMessage containing a single human-friendly description
 * message./*from   w  w  w  . j  a  va 2  s .c o m*/
 *
 * @param moreInfo Page or anchor in the documentation for more information e.g., #search
 */
public ErrorMessage(final int code, final String error, final String moreInfo) {

    this(code, Collections.singletonList(error), "");
}

From source file:com.codecrate.shard.transfer.pcgen.PcgenObjectImporter.java

public Collection getSupportedFileExtensions() {
    return Collections.singletonList(PCGEN_LST_FILE_EXTENSION);
}

From source file:com.googlecode.arit.rhq.ApplicationStatsDiscoveryComponent.java

public Set<DiscoveredResourceDetails> discoverResources(
        ResourceDiscoveryContext<MBeanResourceComponent<?>> context)
        throws InvalidPluginConfigurationException, Exception {
    EmsBean bean = context.getParentResourceComponent().getEmsBean();
    Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>();
    String[] moduleNames = (String[]) bean.refreshAttributes(Collections.singletonList("moduleNames")).get(0)
            .getValue();/*www . j  a va  2s .c  om*/
    if (log.isDebugEnabled()) {
        log.debug("Discovered the following application modules: " + Arrays.asList(moduleNames));
    }
    for (String moduleName : moduleNames) {
        result.add(new DiscoveredResourceDetails(context.getResourceType(), moduleName, moduleName, null,
                "Application statistics", null, null));
    }
    return result;
}

From source file:org.leandreck.endpoints.examples.SecondTypeScriptEndpoint.java

@RequestMapping(value = "/type/{id}", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
public List<SubType> setId(@PathVariable Long id, @RequestBody SubType body) {
    // do something
    return Collections.singletonList(body);
}

From source file:com.vizury.PushNotification.Engine.Sender.java

public Result sendSingleMessage(Message message, String registrationId, String cookie) throws IOException {
    nonNull(registrationId);// w ww.j a  va 2s  .  c  o m
    List<String> registrationIds = Collections.singletonList(registrationId);
    List<String> cookieList = Collections.singletonList(cookie);
    MulticastResult multicastResult = sendMultiCastMessage(message, registrationIds, cookieList);
    if (multicastResult == null) {
        return null;
    }
    List<Result> results = multicastResult.getResults();
    if (results.size() != 1) {
        logger.debug("Found " + results.size() + " results in single multicast request, expected one");
        return null;
    }
    return results.get(0);
}

From source file:org.yamj.api.trakttv.model.SyncItems.java

public SyncItems show(SyncShow show) {
    this.shows = Collections.singletonList(show);
    return this;
}