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