Class ADataContainer
java.lang.Object
com.xzavier0722.mc.plugin.slimefun4.storage.controller.ADataContainer
- Direct Known Subclasses:
ASlimefunDataContainer,SlimefunChunkData
Abstract base class for data containers that store key-value data.
-
Constructor Summary
ConstructorsConstructorDescriptionADataContainer(String key) Constructs a new ADataContainer.ADataContainer(String key, ADataContainer other) Constructs a new ADataContainer by copying data from another container. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if data is loaded and throws an exception if not.Gets all data in this container.protected StringgetCacheInternal(String key) Gets the cached value for the given key.Gets the value for the given key.Gets all keys in this container.getKey()Gets the key of this container.booleanChecks if the data has been loaded.protected StringRemoves a value from the cache.abstract voidremoveData(String key) Removes data from the container.protected voidsetCacheInternal(String key, String val, boolean override) Sets a value in the cache.abstract voidSets data in the container.protected voidsetIsDataLoaded(boolean isDataLoaded) Sets whether the data is loaded.
-
Constructor Details
-
ADataContainer
Constructs a new ADataContainer.- Parameters:
key- The key for this container
-
ADataContainer
Constructs a new ADataContainer by copying data from another container.- Parameters:
key- The key for this containerother- 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
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
Sets a value in the cache.- Parameters:
key- The key to setval- The value to setoverride- Whether to override existing values
-
removeCacheInternal
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
Gets all data in this container.- Returns:
- An unmodifiable map of all data
-
getDataKeys
Gets all keys in this container.- Returns:
- An unmodifiable set of all keys
-
getData
Gets the value for the given key.- Parameters:
key- The key to look up- Returns:
- The value, or null if not found
-
getKey
Gets the key of this container.- Returns:
- The key
-
setData
Sets data in the container.- Parameters:
key- The key to setval- The value to set
-
removeData
Removes data from the container.- Parameters:
key- The key to remove
-