Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created February 10, 2015 03:50
Show Gist options
  • Select an option

  • Save javaeeeee/192147030437f00f2c69 to your computer and use it in GitHub Desktop.

Select an option

Save javaeeeee/192147030437f00f2c69 to your computer and use it in GitHub Desktop.
Dropwizard Sub-resource Guava Optional
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