counter: 1.3.1 - Refined `CounterStreamProcessor` (DRY for type-mapping)
[demos/kafka/wordcount] / src / main / java / de / juplo / kafka / wordcount / counter / CounterStreamProcessor.java
index c983a25..2304e55 100644 (file)
@@ -114,17 +114,17 @@ public class CounterStreamProcessor
 
        private static String typeMappingsConfig()
        {
-               return typeMappings()
-                               .entrySet()
-                               .stream()
-                               .map(entry -> entry.getKey() + ":" + entry.getValue().getName())
-                               .collect(Collectors.joining(","));
+               return typeMappingsConfig(Word.class, WordCounter.class);
        }
 
-       private static Map<String, Class> typeMappings()
+       public static String typeMappingsConfig(Class wordClass, Class wordCounterClass)
        {
                return Map.of(
-                               "word", Word.class,
-                               "counter", WordCounter.class);
+                                               "word", wordClass,
+                                               "counter", wordCounterClass)
+                               .entrySet()
+                               .stream()
+                               .map(entry -> entry.getKey() + ":" + entry.getValue().getName())
+                               .collect(Collectors.joining(","));
        }
 }