package net.minecraft.client.gui.font.providers;

import net.minecraft.Util;
import com.google.common.collect.Maps;
import java.util.HashMap;
import com.google.gson.JsonObject;
import java.util.function.Function;
import java.util.Map;

public enum GlyphProviderBuilderType {
    BITMAP("bitmap", (Function<JsonObject, GlyphProviderBuilder>)BitmapProvider.Builder::fromJson), 
    TTF("ttf", TrueTypeGlyphProviderBuilder::fromJson), 
    LEGACY_UNICODE("legacy_unicode", LegacyUnicodeBitmapsProvider.Builder::fromJson);
    
    private static final Map<String, GlyphProviderBuilderType> BY_NAME;
    private final String name;
    private final Function<JsonObject, GlyphProviderBuilder> factory;
    
    private GlyphProviderBuilderType(final String string3, final Function<JsonObject, GlyphProviderBuilder> function) {
        this.name = string3;
        this.factory = function;
    }
    
    public static GlyphProviderBuilderType byName(final String string) {
        final GlyphProviderBuilderType dpe2 = GlyphProviderBuilderType.BY_NAME.get(string);
        if (dpe2 == null) {
            throw new IllegalArgumentException("Invalid type: " + string);
        }
        return dpe2;
    }
    
    public GlyphProviderBuilder create(final JsonObject jsonObject) {
        return this.factory.apply(jsonObject);
    }
    
    static {
        final GlyphProviderBuilderType[] array;
        int length;
        int i = 0;
        GlyphProviderBuilderType dpe5;
        BY_NAME = Util.<Map<String, GlyphProviderBuilderType>>make(Maps.newHashMap(), hashMap -> {
            values();
            for (length = array.length; i < length; ++i) {
                dpe5 = array[i];
                hashMap.put(dpe5.name, dpe5);
            }
        });
    }
}
