Record Class TransactionOperation

java.lang.Object
java.lang.Record
dev.mintychochip.mint.TransactionOperation

@AvailableSince("1.0") public record TransactionOperation(UUID accountId, Optional<UUID> relatedAccountId, TransactionOperation.Type type, BigDecimal amount, BigDecimal balanceBefore, BigDecimal balanceAfter) extends Record
Immutable record of a single operation executed within a transaction.

Each operation captures the complete state change including the affected account, operation type, amount, and balance deltas.

Properties

Since:
1.0
  • Constructor Details

    • TransactionOperation

      public TransactionOperation(UUID accountId, Optional<UUID> relatedAccountId, TransactionOperation.Type type, BigDecimal amount, BigDecimal balanceBefore, BigDecimal balanceAfter)
      Creates an instance of a TransactionOperation record class.
      Parameters:
      accountId - the value for the accountId record component
      relatedAccountId - the value for the relatedAccountId record component
      type - the value for the type record component
      amount - the value for the amount record component
      balanceBefore - the value for the balanceBefore record component
      balanceAfter - the value for the balanceAfter record component
  • Method Details

    • accountId

      @AvailableSince("1.0") public UUID accountId()
      Gets the primary account affected by this operation.
      Returns:
      the account UUID
    • relatedAccountId

      @AvailableSince("1.0") public Optional<UUID> relatedAccountId()
      Gets the secondary account for transfer operations.

      Present for TRANSFER_TO and TRANSFER_FROM operations, empty otherwise.

      Returns:
      optional related account UUID
    • type

      @AvailableSince("1.0") public TransactionOperation.Type type()
      Gets the category of operation performed.
      Returns:
      the operation type
    • amount

      @AvailableSince("1.0") public BigDecimal amount()
      Gets the amount changed by this operation.
      Returns:
      the operation amount
    • balanceBefore

      @AvailableSince("1.0") public BigDecimal balanceBefore()
      Gets the account balance before this operation executed.
      Returns:
      the balance before
    • balanceAfter

      @AvailableSince("1.0") public BigDecimal balanceAfter()
      Gets the account balance after this operation executed.
      Returns:
      the balance after
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.