Skip to content

Instantly share code, notes, and snippets.

@lefloh
Last active November 21, 2016 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lefloh/b1031535ec1bcb4188e7710e1b07d400 to your computer and use it in GitHub Desktop.
Save lefloh/b1031535ec1bcb4188e7710e1b07d400 to your computer and use it in GitHub Desktop.
CustomersResource#getCustomer
public Customer getCustomer(@PathParam("id") long id, @Context UriInfo uriInfo) {
Optional<Customer> customer = findCustomer(id);
if (!customer.isPresent()) {
throw new NotFoundException(
String.format("No customer with id %d found. RequestUri was %s",
id, uriInfo.getRequestUri()));
}
return customer.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment