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 Details

  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • get

      @Nullable public <T, Z> Z get(@NotNull @NotNull org.bukkit.NamespacedKey key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<T,Z> type)
      Specified by:
      get in interface org.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:
      set in interface org.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:
      has in interface org.bukkit.persistence.PersistentDataContainer
    • getAdapterContext

      @NotNull public @NotNull org.bukkit.persistence.PersistentDataAdapterContext getAdapterContext()
      Specified by:
      getAdapterContext in interface org.bukkit.persistence.PersistentDataContainer
    • has

      public boolean has(@NotNull @NotNull org.bukkit.NamespacedKey key)
      Specified by:
      has in interface org.bukkit.persistence.PersistentDataContainer
    • serializeToBytes

      public byte @NotNull [] serializeToBytes() throws IOException
      Specified by:
      serializeToBytes in interface org.bukkit.persistence.PersistentDataContainer
      Throws:
      IOException
    • readFromBytes

      public void readFromBytes(byte @NotNull [] bytes, boolean clear) throws IOException
      Specified by:
      readFromBytes in interface org.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:
      getOrDefault in interface org.bukkit.persistence.PersistentDataContainer
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface org.bukkit.persistence.PersistentDataContainer
    • copyTo

      public void copyTo(@NotNull @NotNull org.bukkit.persistence.PersistentDataContainer other, boolean replace)
      Specified by:
      copyTo in interface org.bukkit.persistence.PersistentDataContainer
    • remove

      public void remove(@NotNull @NotNull org.bukkit.NamespacedKey key)
      Specified by:
      remove in interface org.bukkit.persistence.PersistentDataContainer
    • getKeys

      @NotNull public @NotNull Set<org.bukkit.NamespacedKey> getKeys()
      Specified by:
      getKeys in interface org.bukkit.persistence.PersistentDataContainer
    • serialize

      @NotNull public @NotNull Map<String,Object> 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 a PersistentDataContainerMock from a map.
      Parameters:
      args - The map to deserialize.
      Returns:
      The deserialized PersistentDataContainerMock.