Transaction

public classTransaction


The Transaction class encapsulates the functionality needed to perform a transaction on the data at a location. To run a transaction, provide aHandler torunTransaction. That handler will be passed the current data at the location, and must return aResult. AResult can be created using eithersuccess orabort.

Summary

Nested types

public interfaceTransaction.Handler

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

public classTransaction.Result

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

Public constructors

Public constructors

Transaction

public Transaction()

Public methods

abort

public static @NonNullTransaction.Result abort()
Returns
@NonNullTransaction.Result

AResult that aborts the transaction

success

public static @NonNullTransaction.Result success(@NonNullMutableData resultData)
Parameters
@NonNullMutableData resultData

The desired data at the location

Returns
@NonNullTransaction.Result

AResult indicating the new data to be stored at the location

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.