Skip to content

Instantly share code, notes, and snippets.

@rlubke
Created October 19, 2021 04:18
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 rlubke/ff3655b91bfcfe915d8196cebad6a5e8 to your computer and use it in GitHub Desktop.
Save rlubke/ff3655b91bfcfe915d8196cebad6a5e8 to your computer and use it in GitHub Desktop.
UPDATE/{id}
@Put(value = "{id}", consumes = MediaType.APPLICATION_JSON)
public Task updateTask(@PathVariable("id") String id, Task task)
{
String description = task.getDescription();
Boolean completed = task.getCompleted();
if (description != null)
{
return tasks.update(id, Task::setDescription, description);
}
else if (completed != null)
{
return tasks.update(id, Task::setCompleted, completed);
}
throw new IllegalArgumentException("either description or completion status must be specified");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment