java.lang.Object
com.xzavier0722.mc.plugin.slimefun4.storage.controller.ADataContainer
Direct Known Subclasses:
ASlimefunDataContainer, SlimefunChunkData

public abstract class ADataContainer extends Object
Abstract base class for data containers that store key-value data.
  • Constructor Details

    • ADataContainer

      @ParametersAreNonnullByDefault public ADataContainer(String key)
      Constructs a new ADataContainer.
      Parameters:
      key - The key for this container
    • ADataContainer

      @ParametersAreNonnullByDefault public ADataContainer(String key, ADataContainer other)
      Constructs a new ADataContainer by copying data from another container.
      Parameters:
      key - The key for this container
      other - The other container to copy data from
  • Method Details

    • isDataLoaded

      public boolean isDataLoaded()
      Checks if the data has been loaded.
      Returns:
      true if data is loaded, false otherwise
    • getCacheInternal

      protected String getCacheInternal(String key)
      Gets the cached value for the given key.
      Parameters:
      key - The key to look up
      Returns:
      The cached value, or null if not found
    • setIsDataLoaded

      protected void setIsDataLoaded(boolean isDataLoaded)
      Sets whether the data is loaded.
      Parameters:
      isDataLoaded - Whether data is loaded
    • setCacheInternal

      protected void setCacheInternal(String key, String val, boolean override)
      Sets a value in the cache.
      Parameters:
      key - The key to set
      val - The value to set
      override - Whether to override existing values
    • removeCacheInternal

      protected String removeCacheInternal(String key)
      Removes a value from the cache.
      Parameters:
      key - The key to remove
      Returns:
      The removed value, or null if not found
    • checkData

      protected void checkData()
      Checks if data is loaded and throws an exception if not.
    • getAllData

      @Nonnull public Map<String,String> getAllData()
      Gets all data in this container.
      Returns:
      An unmodifiable map of all data
    • getDataKeys

      @Nonnull public Set<String> getDataKeys()
      Gets all keys in this container.
      Returns:
      An unmodifiable set of all keys
    • getData

      @Nullable public String getData(String key)
      Gets the value for the given key.
      Parameters:
      key - The key to look up
      Returns:
      The value, or null if not found
    • getKey

      @Nonnull public String getKey()
      Gets the key of this container.
      Returns:
      The key
    • setData

      public abstract void setData(String key, String val)
      Sets data in the container.
      Parameters:
      key - The key to set
      val - The value to set
    • removeData

      public abstract void removeData(String key)
      Removes data from the container.
      Parameters:
      key - The key to remove