Refactoring for better package organization and other changes.
[ovsdb.git] / ovsdb / src / main / java / org / opendaylight / ovsdb / lib / operations / TransactionBuilder.java
diff --git a/ovsdb/src/main/java/org/opendaylight/ovsdb/lib/operations/TransactionBuilder.java b/ovsdb/src/main/java/org/opendaylight/ovsdb/lib/operations/TransactionBuilder.java
new file mode 100644 (file)
index 0000000..df6460f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *
+ *  * Copyright (C) 2014 EBay Software Foundation
+ *  *
+ *  * This program and the accompanying materials are made available under the
+ *  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ *  * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *  *
+ *  * Authors : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.operations;
+
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.ovsdb.lib.OvsDBClientImpl;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TransactionBuilder {
+
+    private DatabaseSchema eDatabaseSchema;
+    OvsDBClientImpl ovs;
+    ArrayList<Operation> operations = Lists.newArrayList();
+
+    public TransactionBuilder(OvsDBClientImpl ovs) {
+        this.ovs = ovs;
+    }
+
+    public TransactionBuilder(DatabaseSchema eDatabaseSchema) {
+        this.eDatabaseSchema = eDatabaseSchema;
+    }
+
+    public TransactionBuilder add(Operation operation) {
+        operations.add(operation);
+        return this;
+    }
+
+    public List<Operation> build() {
+        return operations;
+    }
+
+    public ListenableFuture<List<OperationResult>> execute() {
+        return ovs.transact(operations);
+    }
+}