Record Class TransactionResult

java.lang.Object
java.lang.Record
dev.yowsef.stealablock.api.result.TransactionResult

public record TransactionResult(@NotNull TransactionResult.Status status, double previousBalance, double newBalance, double delta, @Nullable String message) extends Record
Outcome of a money or credits transaction.
  • Constructor Details

    • TransactionResult

      public TransactionResult(@NotNull @NotNull TransactionResult.Status status, double previousBalance, double newBalance, double delta, @Nullable @Nullable String message)
      Creates an instance of a TransactionResult record class.
      Parameters:
      status - the value for the status record component
      previousBalance - the value for the previousBalance record component
      newBalance - the value for the newBalance record component
      delta - the value for the delta record component
      message - the value for the message record component
  • Method Details

    • success

      public boolean success()
    • ok

      @NotNull public static @NotNull TransactionResult ok(double previous, double current, double delta)
    • fail

      @NotNull public static @NotNull TransactionResult fail(@NotNull @NotNull TransactionResult.Status status, double current, @Nullable @Nullable String message)
    • 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 the compare method from their corresponding wrapper classes.
      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.
    • status

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

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

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

      public double delta()
      Returns the value of the delta record component.
      Returns:
      the value of the delta record component
    • message

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