// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.worldgen.cave.shape.distorted;

import com.hypixel.hytale.server.worldgen.cave.shape.CaveNodeShapeEnum;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;
import java.util.function.Consumer;
import java.util.function.BiConsumer;
import java.util.Map;

public final class DistortedShapes
{
    public static final DistortedShape.Factory CYLINDER;
    public static final DistortedShape.Factory ELLIPSE;
    public static final DistortedShape.Factory PIPE;
    private static final Map<String, DistortedShape.Factory> SHAPES;
    
    private DistortedShapes() {
    }
    
    public static void register(final String name, final DistortedShape.Factory factory) {
        DistortedShapes.SHAPES.putIfAbsent(name, factory);
    }
    
    public static void forEach(final BiConsumer<String, DistortedShape.Factory> consumer) {
        DistortedShapes.SHAPES.forEach(consumer);
    }
    
    public static void forEachName(final Consumer<String> consumer) {
        DistortedShapes.SHAPES.keySet().forEach(consumer);
    }
    
    public static void forEachShape(final Consumer<DistortedShape.Factory> consumer) {
        DistortedShapes.SHAPES.values().forEach(consumer);
    }
    
    @Nonnull
    public static DistortedShape.Factory getDefault() {
        return DistortedShapes.PIPE;
    }
    
    @Nonnull
    public static DistortedShape.Factory getOrDefault(final String name) {
        final DistortedShape.Factory factory = DistortedShapes.SHAPES.get(name);
        if (factory == null) {
            return getDefault();
        }
        return factory;
    }
    
    @Nullable
    public static DistortedShape.Factory getByName(final String name) {
        return DistortedShapes.SHAPES.get(name);
    }
    
    static {
        CYLINDER = new DistortedCylinderShape.Factory();
        ELLIPSE = new DistortedEllipsoidShape.Factory();
        PIPE = new DistortedPipeShape.Factory();
        SHAPES = new ConcurrentHashMap<String, DistortedShape.Factory>();
        register(CaveNodeShapeEnum.PIPE.name(), DistortedShapes.PIPE);
        register(CaveNodeShapeEnum.CYLINDER.name(), DistortedShapes.CYLINDER);
        register(CaveNodeShapeEnum.ELLIPSOID.name(), DistortedShapes.ELLIPSE);
    }
}
