Class PersistData<T,D>

java.lang.Object
io.github.vitalforge.persistlib.dataconversion.PersistData<T,D>
Type Parameters:
T - The type of the self.
D - The type of the data.

public class PersistData<T,D> extends Object
Represents data that can be persisted.
  • Constructor Details

    • PersistData

      public PersistData(T self, D data)
      Creates a new instance of the PersistData.
      Parameters:
      self - The self to create the PersistData for.
      data - The data to create the PersistData for.
  • Method Details

    • setFlag

      public PersistData<T,D> setFlag(PersistDataFlags key, boolean value)
      Sets a flag on the data.
      Parameters:
      key - The key of the flag to set.
      value - The value of the flag to set.
      Returns:
      The current instance of the PersistData.
    • getFlag

      @Nullable public @Nullable Boolean getFlag(PersistDataFlags key)
      Retrieves a flag from the data.
      Parameters:
      key - The key of the flag to retrieve.
      Returns:
      The value of the flag, or null if the flag does not exist.
    • getFlag

      public boolean getFlag(PersistDataFlags key, boolean defaultValue)
      Retrieves a flag from the data.
      Parameters:
      key - The key of the flag to retrieve.
      defaultValue - The default value to return if the flag does not exist.
      Returns:
      The value of the flag, or the default value if the flag does not exist.
    • getData

      public D getData()
      Retrieves the data from the PersistData.
      Returns:
      The data from the PersistData.
    • getSelf

      public T getSelf()
      Retrieves the self from the PersistData.
      Returns:
      The self from the PersistData.