package brn.util;

import java.util.HashMap;
import java.util.Map;

/**
 * Many thanks to Ronny.
 */
public abstract class AbstractFluxBox /* <Key, Value, Params> */ {

  private Map /*<Key,Value>*/ fluxBox = new HashMap();

  protected abstract Object /* Value */ createValue(Object /* Key */ key, Object /* Params */ params);

  public Object /* Value */ getObject(Object /* Key */ key, Object /* Params */ params) {
    if (key == null) {
      return createValue(key, params);
    }
    Object /* Value */ result = fluxBox.get(key);
    if (result == null) {
      result = createValue(key, params);
      fluxBox.put(key, result);
    }
    return result;
  }

  public boolean contains(Object /* Key */ key) {
    return fluxBox.get(key) != null;
  }

  public int hashCode() {
    return 1;
  }
}
