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

package com.hypixel.hytale.builtin.hytalegenerator.referencebundle;

import javax.annotation.Nullable;
import java.util.HashMap;
import javax.annotation.Nonnull;
import java.util.Map;

public class ReferenceBundle
{
    @Nonnull
    private final Map<String, Reference> dataLayerMap;
    @Nonnull
    private final Map<String, String> layerTypeMap;
    
    public ReferenceBundle() {
        this.dataLayerMap = new HashMap<String, Reference>();
        this.layerTypeMap = new HashMap<String, String>();
    }
    
    public <T extends Reference> void put(@Nonnull final String name, @Nonnull final Reference reference, @Nonnull final Class<T> type) {
        this.dataLayerMap.put(name, reference);
        this.layerTypeMap.put(name, type.getName());
    }
    
    @Nullable
    public Reference getLayerWithName(@Nonnull final String name) {
        return this.dataLayerMap.get(name);
    }
    
    @Nullable
    public <T extends Reference> T getLayerWithName(@Nonnull final String name, @Nonnull final Class<T> type) {
        final String storedType = this.layerTypeMap.get(name);
        if (storedType == null) {
            return null;
        }
        if (!storedType.equals(type.getName())) {
            return null;
        }
        return (T)this.dataLayerMap.get(name);
    }
}
