brainslug.flow.context.HashMapRegistry Maven / Gradle / Ivy
package brainslug.flow.context;
import java.util.HashMap;
public class HashMapRegistry implements Registry {
HashMap, Object> registry = new HashMap, Object>();
@Override
public T getService(Class serviceClass) {
if(registry.get(serviceClass) == null) {
throw new IllegalStateException("no service with class " + serviceClass + " registered");
}
return (T) registry.get(serviceClass);
}
@Override
public void registerService(Class serviceClass, T serviceInstance) {
if(registry.get(serviceClass) != null) {
throw new IllegalStateException("service class already registered " + serviceClass);
}
registry.put(serviceClass, serviceInstance);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy