From ecdb51bb995f20c0f00b65edb921b1191277e606 Mon Sep 17 00:00:00 2001 From: magoeke Date: Mon, 27 Mar 2023 00:35:07 +0200 Subject: [PATCH] Changed type of users. --- .../src/main/java/de/hftstuttgart/vs/task02/Main.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/task02/src/main/java/de/hftstuttgart/vs/task02/Main.java b/task02/src/main/java/de/hftstuttgart/vs/task02/Main.java index d901437..373cd91 100644 --- a/task02/src/main/java/de/hftstuttgart/vs/task02/Main.java +++ b/task02/src/main/java/de/hftstuttgart/vs/task02/Main.java @@ -1,8 +1,7 @@ package de.hftstuttgart.vs.task02; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import io.javalin.Javalin; @@ -18,9 +17,10 @@ public class Main { public record User(Object id, String firstName, String lastName) {} /** - * Why do we need a synchronized list? + * Why do we use ConcurrentHashMap? + * find a better type for Object (see description above) */ - private final List users = Collections.synchronizedList(new ArrayList<>()); + private static final Map users = new ConcurrentHashMap<>(); /** * Develop a rest api which can execute the following tasks: @@ -31,6 +31,7 @@ public class Main { * Beside developing the functionalities you should also define the endpoints. * * Further Information about http status codes: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes + * More information about javalin: https://javalin.io/documentation#context * * @param args can be ignored */