+package de.juplo.kafka;
+
+import lombok.ToString;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@Document(collection = "statistics")
+@ToString
+public class StatisticsDocument
+{
+ @Id
+ public String id;
+ public String topic;
+ public Integer partition;
+ public Map<String, Long> statistics;
+
+ public StatisticsDocument()
+ {
+ }
+
+ public StatisticsDocument(String topic, Integer partition, Map<String, Long> statistics)
+ {
+ this.partition = partition;
+ this.statistics = statistics;
+ }
+
+ public StatisticsDocument(PartitionStatistics statistics)
+ {
+ this.topic = statistics.getPartition().topic();
+ this.id = statistics.toString();
+ this.partition = statistics.getPartition().partition();
+ this.statistics = new HashMap<>();
+ statistics.getStatistics().forEach(counter -> this.statistics.put(counter.getKey(), counter.getResult()));
+ }
+}