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

pro.jk.ejoker.queue.AbstractTopicProvider Maven / Gradle / Ivy

package pro.jk.ejoker.queue;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class AbstractTopicProvider implements ITopicProvider {

	private final Map, String> topicDict = new HashMap<>();
	
	private final Set allTopics = new HashSet<>();

	@Override
	public String getTopic(T source) {
		return topicDict.get(source.getClass());
	}

	@Override
	public Set GetAllTopics() {
		return allTopics;
	}

	protected Set> getAllTypes() {
		return topicDict.keySet();
	}
	
	protected void registerTopic(String topic, Class[] types) {
		for(Class type : types)
			topicDict.put(type, topic);
		if(!allTopics.contains(topic)) allTopics.add(topic);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy