ROT: Signatur für `AdderBusinessLogic` und neue Erwartungen formuliert
[demos/kafka/training] / src / main / java / de / juplo / kafka / AdderBusinessLogic.java
index 503fa88..ecd9590 100644 (file)
@@ -22,14 +22,6 @@ public class AdderBusinessLogic
   }
 
 
-  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);
-  }
-
   public synchronized Optional<Long> getSum(String user)
   {
     return Optional.ofNullable(state.get(user));
@@ -46,11 +38,16 @@ public class AdderBusinessLogic
     state.put(user, result);
   }
 
-  public synchronized Long endSum(String user)
+  public synchronized Long calculate(String user)
   {
     if (!state.containsKey(user))
       throw new IllegalStateException("No sumation for " + user + " in progress");
 
-    return state.get(user);
+    return state.remove(user);
+  }
+
+  protected Map<String, Long> getState()
+  {
+    return state;
   }
 }