Class ModifyRecord<T>

java.lang.Object
io.github.darvil.utils.ModifyRecord<T>
Type Parameters:
T - The type of the inner value.

public class ModifyRecord<T> extends Object
Provides a way to see if the inner value has been modified since the constructor was called.
  • Method Details

    • of

      public static <T> ModifyRecord<T> of(@NotNull T value)
      Creates a new ModifyRecord with the given value.
      Type Parameters:
      T - The type of the value.
      Parameters:
      value - The value to store.
      Returns:
      A new ModifyRecord with the given value.
    • empty

      public static <T> ModifyRecord<T> empty()
      Creates a new empty ModifyRecord.
      Type Parameters:
      T - The type of the value.
      Returns:
      A new empty ModifyRecord.
    • get

      public T get()
      Returns the value stored in the ModifyRecord.
      Returns:
      The value stored in the ModifyRecord.
    • set

      public void set(T value)
      Sets the value to the specified value and marks this ModifyRecord as modified.
      Parameters:
      value - The value to set.
    • set

      public void set(@NotNull @NotNull ModifyRecord<T> value)
      Sets the value to the value provided by the specified ModifyRecord and marks this ModifyRecord as modified.
      Parameters:
      value - The value to set.
    • setIfNotModified

      public void setIfNotModified(T value)
      Sets the value to the specified value if it has not been modified.
      Parameters:
      value - The value to set.
    • setIfNotModified

      public void setIfNotModified(@NotNull @NotNull ModifyRecord<T> value)
      Sets the value to the specified value if it has not been modified. The value is provided by the specified ModifyRecord.
      Parameters:
      value - The value to set.
    • isModified

      public boolean isModified()
      Returns true if the value has been modified.
      Returns:
      true if the value has been modified.
    • toString

      public String toString()
      Overrides:
      toString in class Object