Merge "L3: Add eth to br-ex"
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / operations / TransactionBuilder.java
1 /*
2  * Copyright (c) 2014 EBay Software Foundation and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.ovsdb.lib.operations;
10
11 import java.util.List;
12
13 import org.opendaylight.ovsdb.lib.OvsdbClient;
14 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
15
16 import com.google.common.collect.Lists;
17 import com.google.common.util.concurrent.ListenableFuture;
18
19 public class TransactionBuilder {
20
21     private DatabaseSchema databaseSchema;
22     OvsdbClient ovs;
23     List<Operation> operations = Lists.newArrayList();
24
25     public TransactionBuilder(OvsdbClient ovs, DatabaseSchema schema) {
26         this.ovs = ovs;
27         databaseSchema = schema;
28     }
29
30     public List<Operation> getOperations() {
31         return operations;
32     }
33
34     public TransactionBuilder add(Operation operation) {
35         operations.add(operation);
36         return this;
37     }
38
39     public List<Operation> build() {
40         return operations;
41     }
42
43     public ListenableFuture<List<OperationResult>> execute() {
44         return ovs.transact(databaseSchema, operations);
45     }
46
47     public DatabaseSchema getDatabaseSchema() {
48         return databaseSchema;
49     }
50 }