package com.hypixel.hytale.builtin.hytalegenerator.referencebundle; import java.util.HashMap; import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ReferenceBundle { @Nonnull private final Map dataLayerMap = new HashMap<>(); @Nonnull private final Map layerTypeMap = new HashMap<>(); public void put(@Nonnull String name, @Nonnull Reference reference, @Nonnull Class type) { this.dataLayerMap.put(name, reference); this.layerTypeMap.put(name, type.getName()); } @Nullable public Reference getLayerWithName(@Nonnull String name) { return this.dataLayerMap.get(name); } @Nullable public T getLayerWithName(@Nonnull String name, @Nonnull Class type) { String storedType = this.layerTypeMap.get(name); if (storedType == null) { return null; } else { return (T)(!storedType.equals(type.getName()) ? null : this.dataLayerMap.get(name)); } } }