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

brainslug.flow.context.HashMapRegistry Maven / Gradle / Ivy

There is a newer version: 0.21
Show newest version
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