Created
October 19, 2021 04:18
-
-
Save rlubke/ff3655b91bfcfe915d8196cebad6a5e8 to your computer and use it in GitHub Desktop.
UPDATE/{id}
This file contains 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
@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