Class PersistentDataContainerMock
java.lang.Object
be.seeseemelk.mockbukkit.persistence.PersistentDataContainerMock
- All Implemented Interfaces:
PersistentDataContainerView,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 PersistentDataContainer other, boolean replace) static @NotNull PersistentDataContainerMockdeserialize(@NotNull Map<String, Object> args) Deserializes aPersistentDataContainerMockfrom 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) booleanhas(@NotNull NamespacedKey key) <T,Z> boolean has(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type) inthashCode()booleanisEmpty()voidreadFromBytes(byte @NotNull [] bytes, boolean clear) voidremove(@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, 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 NamespacedKey key, @NotNull @NotNull PersistentDataType<T, Z> type) - Specified by:
getin interfacePersistentDataContainerView
-
set
public <T,Z> void set(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull PersistentDataType<T, Z> type, @NotNull Z value) - Specified by:
setin interfacePersistentDataContainer
-
has
public <T,Z> boolean has(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull PersistentDataType<T, Z> type) - Specified by:
hasin interfacePersistentDataContainerView
-
getAdapterContext
- Specified by:
getAdapterContextin interfacePersistentDataContainerView
-
has
- Specified by:
hasin interfacePersistentDataContainerView
-
serializeToBytes
- Specified by:
serializeToBytesin interfacePersistentDataContainerView- Throws:
IOException
-
readFromBytes
- Specified by:
readFromBytesin 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:
getOrDefaultin interfacePersistentDataContainerView
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacePersistentDataContainerView
-
copyTo
- Specified by:
copyToin interfacePersistentDataContainerView
-
remove
- Specified by:
removein interfacePersistentDataContainer
-
getKeys
- Specified by:
getKeysin interfacePersistentDataContainerView
-
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.
-