Class PersistentDataContainerMock
java.lang.Object
be.seeseemelk.mockbukkit.persistence.PersistentDataContainerMock
- All Implemented Interfaces:
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 newPersistentDataContainerMock
with no stored data.PersistentDataContainerMock
(@NotNull PersistentDataContainerMock mock) Constructs a newPersistentDataContainerMock
, cloning the data of another. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull PersistentDataContainerMock
deserialize
(@NotNull Map<String, Object> args) Deserializes aPersistentDataContainerMock
from a map.boolean
<T,
Z> Z get
(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type) @NotNull PersistentDataAdapterContext
@NotNull Set<NamespacedKey>
getKeys()
<T,
Z> Z getOrDefault
(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, Z defaultValue) boolean
has
(@NotNull NamespacedKey key) <T,
Z> boolean has
(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type) int
hashCode()
boolean
isEmpty()
void
readFromBytes
(byte @NotNull [] bytes, boolean clear) void
remove
(@NotNull NamespacedKey key) Serializes the held data.byte @NotNull []
<T,
Z> void set
(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, Z value) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bukkit.persistence.PersistentDataContainer
readFromBytes
-
Constructor Details
-
PersistentDataContainerMock
public PersistentDataContainerMock()Constructs a newPersistentDataContainerMock
with no stored data. -
PersistentDataContainerMock
Constructs a newPersistentDataContainerMock
, cloning the data of another.- Parameters:
mock
- ThePersistentDataContainerMock
to clone.
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
get
@Nullable public <T,Z> Z get(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull PersistentDataType<T, Z> type) - Specified by:
get
in interfacePersistentDataContainer
-
set
public <T,Z> void set(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull PersistentDataType<T, Z> type, @NotNull Z value) - Specified by:
set
in interfacePersistentDataContainer
-
has
public <T,Z> boolean has(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull PersistentDataType<T, Z> type) - Specified by:
has
in interfacePersistentDataContainer
-
getAdapterContext
- Specified by:
getAdapterContext
in interfacePersistentDataContainer
-
has
- Specified by:
has
in interfacePersistentDataContainer
-
serializeToBytes
- Specified by:
serializeToBytes
in interfacePersistentDataContainer
- Throws:
IOException
-
readFromBytes
- Specified by:
readFromBytes
in interfacePersistentDataContainer
- Throws:
IOException
-
getOrDefault
@NotNull public <T,Z> Z getOrDefault(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull PersistentDataType<T, Z> type, @NotNull Z defaultValue) - Specified by:
getOrDefault
in interfacePersistentDataContainer
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfacePersistentDataContainer
-
remove
- Specified by:
remove
in interfacePersistentDataContainer
-
getKeys
- Specified by:
getKeys
in interfacePersistentDataContainer
-
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 aPersistentDataContainerMock
from a map.- Parameters:
args
- The map to deserialize.- Returns:
- The deserialized
PersistentDataContainerMock
.
-