Class PersistentDataContainerMock
java.lang.Object
be.seeseemelk.mockbukkit.persistence.PersistentDataContainerMock
- All Implemented Interfaces:
org.bukkit.persistence.PersistentDataContainer
public class PersistentDataContainerMock
extends Object
implements org.bukkit.persistence.PersistentDataContainer
This is a mock of the
PersistentDataContainer interface to allow the "persistent" storage of data. Only that
it isn't persistent of course since it only ever exists in a test environment.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newPersistentDataContainerMockwith no stored data.PersistentDataContainerMock(@NotNull PersistentDataContainerMock mock) Constructs a newPersistentDataContainerMock, cloning the data of another. -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyTo(@NotNull org.bukkit.persistence.PersistentDataContainer other, boolean replace) static @NotNull PersistentDataContainerMockdeserialize(@NotNull Map<String, Object> args) Deserializes aPersistentDataContainerMockfrom a map.boolean<T,Z> Z get(@NotNull org.bukkit.NamespacedKey key, @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type) @NotNull org.bukkit.persistence.PersistentDataAdapterContext@NotNull Set<org.bukkit.NamespacedKey> getKeys()<T,Z> Z getOrDefault(@NotNull org.bukkit.NamespacedKey key, @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type, Z defaultValue) booleanhas(@NotNull org.bukkit.NamespacedKey key) <T,Z> boolean has(@NotNull org.bukkit.NamespacedKey key, @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type) inthashCode()booleanisEmpty()voidreadFromBytes(byte @NotNull [] bytes, boolean clear) voidremove(@NotNull org.bukkit.NamespacedKey key) Serializes the held data.byte @NotNull []<T,Z> void set(@NotNull org.bukkit.NamespacedKey key, @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type, Z value) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bukkit.persistence.PersistentDataContainer
readFromBytes
-
Constructor Details
-
PersistentDataContainerMock
public PersistentDataContainerMock()Constructs a newPersistentDataContainerMockwith no stored data. -
PersistentDataContainerMock
Constructs a newPersistentDataContainerMock, cloning the data of another.- Parameters:
mock- ThePersistentDataContainerMockto clone.
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
get
@Nullable public <T,Z> Z get(@NotNull @NotNull org.bukkit.NamespacedKey key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type) - Specified by:
getin interfaceorg.bukkit.persistence.PersistentDataContainer
-
set
public <T,Z> void set(@NotNull @NotNull org.bukkit.NamespacedKey key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type, @NotNull Z value) - Specified by:
setin interfaceorg.bukkit.persistence.PersistentDataContainer
-
has
public <T,Z> boolean has(@NotNull @NotNull org.bukkit.NamespacedKey key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type) - Specified by:
hasin interfaceorg.bukkit.persistence.PersistentDataContainer
-
getAdapterContext
@NotNull public @NotNull org.bukkit.persistence.PersistentDataAdapterContext getAdapterContext()- Specified by:
getAdapterContextin interfaceorg.bukkit.persistence.PersistentDataContainer
-
has
public boolean has(@NotNull @NotNull org.bukkit.NamespacedKey key) - Specified by:
hasin interfaceorg.bukkit.persistence.PersistentDataContainer
-
serializeToBytes
- Specified by:
serializeToBytesin interfaceorg.bukkit.persistence.PersistentDataContainer- Throws:
IOException
-
readFromBytes
- Specified by:
readFromBytesin interfaceorg.bukkit.persistence.PersistentDataContainer- Throws:
IOException
-
getOrDefault
@NotNull public <T,Z> Z getOrDefault(@NotNull @NotNull org.bukkit.NamespacedKey key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<T, Z> type, @NotNull Z defaultValue) - Specified by:
getOrDefaultin interfaceorg.bukkit.persistence.PersistentDataContainer
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceorg.bukkit.persistence.PersistentDataContainer
-
copyTo
public void copyTo(@NotNull @NotNull org.bukkit.persistence.PersistentDataContainer other, boolean replace) - Specified by:
copyToin interfaceorg.bukkit.persistence.PersistentDataContainer
-
remove
public void remove(@NotNull @NotNull org.bukkit.NamespacedKey key) - Specified by:
removein interfaceorg.bukkit.persistence.PersistentDataContainer
-
getKeys
- Specified by:
getKeysin interfaceorg.bukkit.persistence.PersistentDataContainer
-
serialize
Serializes the held data.- Returns:
- The serialized data.
- See Also:
-
deserialize
@NotNull public static @NotNull PersistentDataContainerMock deserialize(@NotNull @NotNull Map<String, Object> args) Deserializes aPersistentDataContainerMockfrom a map.- Parameters:
args- The map to deserialize.- Returns:
- The deserialized
PersistentDataContainerMock.
-