Record Class TransactionResult
java.lang.Object
java.lang.Record
com.loomcache.server.transaction.TransactionResult
- Record Components:
succeeded- true if all conditions were met and THEN operations executed, false if any condition failed and ELSE operations executedresponses- unmodifiable list of responses from executed operations (never null)
Result of executing an atomic transaction.
Semantics: Indicates whether the transaction succeeded (all conditions met and THEN branch executed) or failed (any condition failed and ELSE branch executed), along with the results of the executed operations.
Immutability: This record is immutable. The responses list is unmodifiable, preventing accidental mutations after transaction execution.
Use Cases:
- Check succeeded() to determine if conditions were met
- Retrieve responses() to get operation results (GET operations, etc.)
- Use for audit logging and transaction replay
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionTransactionResult(boolean succeeded, List<String> responses) Compact constructor for validation. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static TransactionResultfailure()Creates a failed transaction result with no responses.static TransactionResultCreates a failed transaction result with the given responses.final inthashCode()Returns a hash code value for this object.Returns the value of theresponsesrecord component.booleanReturns the value of thesucceededrecord component.static TransactionResultsuccess()Creates a successful transaction result with no responses.static TransactionResultCreates a successful transaction result with the given responses.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TransactionResult
Compact constructor for validation.Ensures responses is not null and converts it to an unmodifiable list.
- Throws:
NullPointerException- if responses is null
-
-
Method Details
-
success
Creates a successful transaction result with the given responses.- Parameters:
responses- the responses from the executed THEN operations (must not be null)- Returns:
- a successful TransactionResult (never null)
- Throws:
NullPointerException- if responses is null
-
failure
Creates a failed transaction result with the given responses.- Parameters:
responses- the responses from the executed ELSE operations (must not be null)- Returns:
- a failed TransactionResult (never null)
- Throws:
NullPointerException- if responses is null
-
success
Creates a successful transaction result with no responses.- Returns:
- a successful TransactionResult with an empty responses list (never null)
-
failure
Creates a failed transaction result with no responses.- Returns:
- a failed TransactionResult with an empty responses list (never null)
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
succeeded
-
responses
-