Created
February 10, 2015 03:50
-
-
Save javaeeeee/192147030437f00f2c69 to your computer and use it in GitHub Desktop.
Dropwizard Sub-resource Guava Optional
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String getTailoredGreetingWithQueryParam( | |
| @QueryParam("name") Optional<String> name) { | |
| if (name.isPresent()) { | |
| return "Hello " + name.get(); | |
| } else { | |
| return "Hello world"; | |
| } | |
| //The same can be accomplished using or(...) method to provide the default value | |
| //return "Hello " + name.or("world"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment