pl.allegro.tech.hermes.domain.topic.preview.TopicsMessagesPreview Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-common Show documentation
Show all versions of hermes-common Show documentation
Fast and reliable message broker built on top of Kafka.
The newest version!
package pl.allegro.tech.hermes.domain.topic.preview;
import pl.allegro.tech.hermes.api.TopicName;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TopicsMessagesPreview {
private final Map> messages = new HashMap<>();
public void add(TopicName topicName, MessagePreview message) {
List messageList = messages.computeIfAbsent(topicName, k -> new ArrayList<>());
messageList.add(message);
}
public Collection topics() {
return messages.keySet();
}
public List previewOf(TopicName topic) {
return messages.getOrDefault(topic, new ArrayList<>());
}
}