class Metric2Registry implements Metric2Set {

	@SuppressWarnings("unchecked")
	public <T extends Metric> T register(MetricName name, T metric) throws IllegalArgumentException {
		if (metric instanceof MetricSet) {
			throw new IllegalArgumentException("This metrics registry is not compatible with MetricSets. Use a Metric2Set instead.");
		} else {
			final Metric existing = metrics.putIfAbsent(name, metric);
			if (existing != null) {
				throw new IllegalArgumentException("A metric named " + name + " already exists");
			}
			else {
				// This is a new metric - we have to register the Metric with
				// the legacy Dropwizard Metric registry as
				// well to support existing reports and listeners
				metricRegistry.register(name.toGraphiteName(), metric);
			}
		}
		return metric;
	}

	public  Metric2Registry();
	public  Metric2Registry(MetricRegistry metricRegistry);

}