Record Class CurrencyTransaction

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.currency.CurrencyTransaction
Record Components:
playerId - the player whose balance it was
status - the outcome
oldBalance - the balance before the change, as storage held it; the cached balance when the change never reached storage
newBalance - the balance after it; equal to oldBalance unless it was applied
requestedAmount - the change asked for: the amount for a deposit or withdrawal, the difference for a set or reset
source - the source the caller gave, as CurrencyChangeEvent reported it
failure - why it failed, for CurrencyTransaction.Status.FAILED and CurrencyTransaction.Status.UNAVAILABLE; null otherwise

public record CurrencyTransaction(@NotNull UUID playerId, @NotNull CurrencyTransaction.Status status, double oldBalance, double newBalance, double requestedAmount, @NotNull String source, @Nullable String failure) extends Record
What a balance change requested through CurrencyService actually did.
Since:
1.8.0
  • Constructor Details

    • CurrencyTransaction

      public CurrencyTransaction(@NotNull @NotNull UUID playerId, @NotNull @NotNull CurrencyTransaction.Status status, double oldBalance, double newBalance, double requestedAmount, @NotNull @NotNull String source, @Nullable @Nullable String failure)
      Creates an instance of a CurrencyTransaction record class.
      Parameters:
      playerId - the value for the playerId record component
      status - the value for the status record component
      oldBalance - the value for the oldBalance record component
      newBalance - the value for the newBalance record component
      requestedAmount - the value for the requestedAmount record component
      source - the value for the source record component
      failure - the value for the failure record component
  • Method Details

    • refused

      @NotNull public static @NotNull CurrencyTransaction refused(@NotNull @NotNull UUID playerId, @NotNull @NotNull CurrencyTransaction.Status status, double balance, double requestedAmount, @NotNull @NotNull String source, @Nullable @Nullable String failure)
      A change that was refused before anything was asked of storage or listeners.
    • isApplied

      public boolean isApplied()
      Whether the balance changed, exactly as requested or as a listener adjusted it.
    • appliedAmount

      public double appliedAmount()
      How much the balance really moved; negative for a loss.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • playerId

      @NotNull public @NotNull UUID playerId()
      Returns the value of the playerId record component.
      Returns:
      the value of the playerId record component
    • status

      @NotNull public @NotNull CurrencyTransaction.Status status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • oldBalance

      public double oldBalance()
      Returns the value of the oldBalance record component.
      Returns:
      the value of the oldBalance record component
    • newBalance

      public double newBalance()
      Returns the value of the newBalance record component.
      Returns:
      the value of the newBalance record component
    • requestedAmount

      public double requestedAmount()
      Returns the value of the requestedAmount record component.
      Returns:
      the value of the requestedAmount record component
    • source

      @NotNull public @NotNull String source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • failure

      @Nullable public @Nullable String failure()
      Returns the value of the failure record component.
      Returns:
      the value of the failure record component