Transaction

public class Transaction


The Transaction class encapsulates the functionality needed to perform a transaction on the data at a location. To run a transaction, provide a Handler to runTransaction. That handler will be passed the current data at the location, and must return a Result. A Result can be created using either success or abort.

Summary

Nested types

public interface Transaction.Handler

An object implementing this interface is used to run a transaction, and will be notified of the results of the transaction.

public class Transaction.Result

Instances of this class represent the desired outcome of a single run of a Handler's doTransaction method.

Public constructors

Public methods

static @NonNull Transaction.Result
static @NonNull Transaction.Result

Public constructors

Transaction

public Transaction()

Public methods

abort

public static @NonNull Transaction.Result abort()
Returns
@NonNull Transaction.Result

A Result that aborts the transaction

success

public static @NonNull Transaction.Result success(@NonNull MutableData resultData)
Parameters
@NonNull MutableData resultData

The desired data at the location

Returns
@NonNull Transaction.Result

A Result indicating the new data to be stored at the location