From 47657918b484fad60ac4062177cfeb569275d3d3 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 13 Aug 2022 15:19:54 +0200 Subject: [PATCH] =?utf8?q?GR=C3=9CN:=20Erwartungen=20implementiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../de/juplo/kafka/AdderBusinessLogic.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/de/juplo/kafka/AdderBusinessLogic.java b/src/main/java/de/juplo/kafka/AdderBusinessLogic.java index 2e3d126..a3848c4 100644 --- a/src/main/java/de/juplo/kafka/AdderBusinessLogic.java +++ b/src/main/java/de/juplo/kafka/AdderBusinessLogic.java @@ -1,13 +1,31 @@ package de.juplo.kafka; +import java.util.HashMap; +import java.util.Map; + + public class AdderBusinessLogic { + private final Map state; + + public AdderBusinessLogic() { + this(new HashMap<>()); } + public AdderBusinessLogic(Map state) + { + this.state = state; + } + + public synchronized void startSum(String user) { + if (state.containsKey(user)) + throw new IllegalStateException("Sumation for " + user + " already in progress, state: " + state.get(user)); + + state.put(user, 0l); } } -- 2.20.1