Example usage for java.util Collections singletonMap

List of usage examples for java.util Collections singletonMap

Introduction

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

Prototype

public static <K, V> Map<K, V> singletonMap(K key, V value) 

Source Link

Document

Returns an immutable map, mapping only the specified key to the specified value.

Usage

From source file:org.ambient.rest.SetCurrentClimateProfileTask.java

@Override
protected Void doInBackground(String... params) {

    try {//from   ww  w  .  ja  v  a 2 s  . co  m
        String url = Rest.getUrl(URL);
        Map<String, String> vars = Collections.singletonMap("roomName", params[0]);

        RestTemplate restTemplate = Rest.getRestTemplate();

        restTemplate.put(url, params[1], vars);
    } catch (Exception e) {
        Log.e(LOG, e.getMessage());
    }

    return null;
}

From source file:thymeleafsandbox.springjsp.web.controller.jsp.JspExp.java

@RequestMapping("/jsp/exp")
public String showExp(final ModelMap modelMap) {
    modelMap.addAttribute("aMap", Collections.singletonMap("aKey", "ONE VALUE!"));
    return "jsp/exp";
}

From source file:org.cloudfoundry.practical.demo.web.controller.MainController.java

@RequestMapping({ "/", "/index.html" })
public ModelAndView index() {
    return new ModelAndView("index", Collections.singletonMap("username", this.userDetails.getUsername()));
}

From source file:org.springsecurity.oauth2.oauth.OAuth2TokenEnhancer.java

@Override
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
    DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
    result.setAdditionalInformation(//  w  w  w .  j a v a 2 s  .c om
            Collections.singletonMap("client_id", (Object) authentication.getOAuth2Request().getClientId()));
    return result;
}

From source file:comsat.sample.actuator.log4j.SampleController.java

@RequestMapping("/")
@ResponseBody/*from ww  w.jav a2s  . c o  m*/
public Map<String, String> helloWorld() throws InterruptedException, SuspendExecution {
    Fiber.sleep(10);
    return Collections.singletonMap("message", this.helloWorldService.getHelloMessage());
}

From source file:com.example.autoconfigure.listener.ExampleApplicationListener.java

@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    System.err.println("Adding extra properties");
    PropertySource<?> propertySource = new MapPropertySource("example",
            Collections.singletonMap("example.secret", "the-secret-key"));
    event.getEnvironment().getPropertySources().addFirst(propertySource);
}

From source file:thymeleafsandbox.springjsp.web.controller.thymeleaf.ThymeleafExp.java

@RequestMapping("/thymeleaf/exp")
public String showExp(final ModelMap modelMap) {
    modelMap.addAttribute("aMap", Collections.singletonMap("aKey", "ONE VALUE!"));
    return "thymeleaf/exp";
}

From source file:com.bearingpoint.opencms.workflow2.events.WorkflowEventGun.java

/**
 * Generic fire event method to fire unspecified events.
 * You have to take care that EVENT_ID //from   w w w. j ava  2 s.c om
 * <p>
 * @param EVENT_ID
 * @param object
 */
public static void fireEvent(final int EVENT_ID, Object object) {

    Map data = Collections.singletonMap("data", object);
    OpenCms.fireCmsEvent(EVENT_ID, data);
    if (LOG.isInfoEnabled()) {
        LOG.info("WF2 EVENT FIRED [ID:" + EVENT_ID + "]");
    }
}

From source file:com.cloudbees.jenkins.plugins.demo.actuator.SampleController.java

@RequestMapping("/")
@ResponseBody//ww w .  j a va 2s.c  o  m
public Map<String, String> helloWorld() {
    return Collections.singletonMap("message", this.helloWorldService.getHelloMessage());
}

From source file:com.graphaware.server.CommunityTxParticipationIntegrationTest.java

@Test
public void invalidTransactionShouldResultInException() {
    httpClient.get(baseUrl() + "/greeting", Collections.singletonMap("_GA_TX_ID", "invalid"),
            HttpStatus.SC_BAD_REQUEST);
}