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

package com.hypixel.hytale.assetstore;

import javax.annotation.Nonnull;
import java.util.Iterator;
import java.util.Collections;
import java.util.Set;
import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;

public class AssetReferences<CK, C extends JsonAssetWithMap<CK, ?>>
{
    private final Class<C> parentAssetClass;
    private final Set<CK> parentKeys;
    
    public AssetReferences(final Class<C> parentAssetClass, final Set<CK> parentKeys) {
        this.parentAssetClass = parentAssetClass;
        this.parentKeys = parentKeys;
    }
    
    public Class<C> getParentAssetClass() {
        return this.parentAssetClass;
    }
    
    public Set<CK> getParentKeys() {
        return this.parentKeys;
    }
    
    public <T extends JsonAssetWithMap<K, ?>, K> void addChildAssetReferences(final Class<T> tClass, final K childKey) {
        final Class parentAssetClass = this.parentAssetClass;
        final AssetStore<CK, C, ?> assetStore = AssetRegistry.getAssetStore((Class<C>)parentAssetClass);
        for (final CK parentKey : this.parentKeys) {
            assetStore.addChildAssetReferences(parentKey, (Class<? extends JsonAssetWithMap<Object, ?>>)tClass, (Set<Object>)Collections.singleton((CK)childKey));
        }
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "AssetReferences{parentAssetClass=" + String.valueOf(this.parentAssetClass) + ", parentKeys=" + String.valueOf(this.parentKeys);
    }
}
