All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.hermes.domain.topic.preview.TopicsMessagesPreview Maven / Gradle / Ivy

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<>());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy