io.etcd.jetcd

## Interface Txn

All Known Implementing Classes:
  TxnImpl

    public interface Txn

Txn is the interface that wraps mini-transactions.

### Usage examples

     txn.If(
        new Cmp(KEY, Cmp.Op.GREATER, CmpTarget.value(VALUE)),
        new Cmp(KEY, cmp.Op.EQUAL, CmpTarget.version(2))
     ).Then(
        Op.put(KEY2, VALUE2, PutOption.DEFAULT),
        Op.put(KEY3, VALUE3, PutOption.DEFAULT)
     ).Else(
        Op.put(KEY4, VALUE4, PutOption.DEFAULT),
        Op.put(KEY4, VALUE4, PutOption.DEFAULT)
     ).commit();

Txn also supports If, Then, and Else chaining. e.g.

     txn.If(
        new Cmp(KEY, Cmp.Op.GREATER, CmpTarget.value(VALUE))
     ).If(
        new Cmp(KEY, cmp.Op.EQUAL, CmpTarget.version(VERSION))
     ).Then(
        Op.put(KEY2, VALUE2, PutOption.DEFAULT)
     ).Then(
        Op.put(KEY3, VALUE3, PutOption.DEFAULT)
     ).Else(
        Op.put(KEY4, VALUE4, PutOption.DEFAULT)
     ).Else(
        Op.put(KEY4, VALUE4, PutOption.DEFAULT)
     ).commit();

### Method Summary

All Methods Instance Methods Abstract Methods
`CompletableFuture<TxnResponse>` `commit()` tries to commit the transaction.
`Txn` `Else(Op... ops)` takes a list of operations.
`Txn` `If(Cmp... cmps)` takes a list of comparison.
`Txn` `Then(Op... ops)` takes a list of operations.

### Method Detail

#### If

    Txn If(Cmp... cmps)

takes a list of comparison. If all comparisons passed in succeed, the operations passed into Then() will be executed. Or the operations passed into Else() will be executed.

#### Then

    Txn Then(Op... ops)

takes a list of operations. The Ops list will be executed, if the comparisons passed in If() succeed.

#### Else

    Txn Else(Op... ops)

takes a list of operations. The Ops list will be executed, if the comparisons passed in If() fail.

#### commit

    CompletableFuture<TxnResponse> commit()

tries to commit the transaction.

Returns:
  a TxnResponse wrapped in CompletableFuture