package net.minecraft.stats;

import java.util.Iterator;
import java.util.IdentityHashMap;
import java.util.Map;
import net.minecraft.core.Registry;

public class StatType<T> implements Iterable<Stat<T>> {
    private final Registry<T> registry;
    private final Map<T, Stat<T>> map;
    
    public StatType(final Registry<T> gb) {
        this.map = new IdentityHashMap<T, Stat<T>>();
        this.registry = gb;
    }
    
    public boolean contains(final T object) {
        return this.map.containsKey(object);
    }
    
    public Stat<T> get(final T object, final StatFormatter aap) {
        return this.map.computeIfAbsent(object, object -> new Stat((StatType<Object>)this, object, aap));
    }
    
    public Registry<T> getRegistry() {
        return this.registry;
    }
    
    @Override
    public Iterator<Stat<T>> iterator() {
        return this.map.values().iterator();
    }
    
    public Stat<T> get(final T object) {
        return this.get(object, StatFormatter.DEFAULT);
    }
    
    public String getTranslationKey() {
        return "stat_type." + Registry.STAT_TYPE.getKey(this).toString().replace(':', '.');
    }
}
