Record Class CurrencyTransaction
java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.currency.CurrencyTransaction
- Record Components:
playerId- the player whose balance it wasstatus- the outcomeoldBalance- the balance before the change, as storage held it; the cached balance when the change never reached storagenewBalance- the balance after it; equal tooldBalanceunless it was appliedrequestedAmount- the change asked for: the amount for a deposit or withdrawal, the difference for a set or resetsource- the source the caller gave, asCurrencyChangeEventreported itfailure- why it failed, forCurrencyTransaction.Status.FAILEDandCurrencyTransaction.Status.UNAVAILABLE;nullotherwise
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe outcome of a balance change. -
Constructor Summary
ConstructorsConstructorDescriptionCurrencyTransaction(@NotNull UUID playerId, @NotNull CurrencyTransaction.Status status, double oldBalance, double newBalance, double requestedAmount, @NotNull String source, @Nullable String failure) Creates an instance of aCurrencyTransactionrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleHow much the balance really moved; negative for a loss.final booleanIndicates whether some other object is "equal to" this one.@Nullable Stringfailure()Returns the value of thefailurerecord component.final inthashCode()Returns a hash code value for this object.booleanWhether the balance changed, exactly as requested or as a listener adjusted it.doubleReturns the value of thenewBalancerecord component.doubleReturns the value of theoldBalancerecord component.@NotNull UUIDplayerId()Returns the value of theplayerIdrecord component.static @NotNull CurrencyTransactionrefused(@NotNull UUID playerId, @NotNull CurrencyTransaction.Status status, double balance, double requestedAmount, @NotNull String source, @Nullable String failure) A change that was refused before anything was asked of storage or listeners.doubleReturns the value of therequestedAmountrecord component.@NotNull Stringsource()Returns the value of thesourcerecord component.@NotNull CurrencyTransaction.Statusstatus()Returns the value of thestatusrecord component.final StringtoString()Returns a string representation of this record class.
-
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 aCurrencyTransactionrecord class.- Parameters:
playerId- the value for theplayerIdrecord componentstatus- the value for thestatusrecord componentoldBalance- the value for theoldBalancerecord componentnewBalance- the value for thenewBalancerecord componentrequestedAmount- the value for therequestedAmountrecord componentsource- the value for thesourcerecord componentfailure- the value for thefailurerecord 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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
playerId
Returns the value of theplayerIdrecord component.- Returns:
- the value of the
playerIdrecord component
-
status
Returns the value of thestatusrecord component.- Returns:
- the value of the
statusrecord component
-
oldBalance
public double oldBalance()Returns the value of theoldBalancerecord component.- Returns:
- the value of the
oldBalancerecord component
-
newBalance
public double newBalance()Returns the value of thenewBalancerecord component.- Returns:
- the value of the
newBalancerecord component
-
requestedAmount
public double requestedAmount()Returns the value of therequestedAmountrecord component.- Returns:
- the value of the
requestedAmountrecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
failure
Returns the value of thefailurerecord component.- Returns:
- the value of the
failurerecord component
-