Merge "Updating fix for bug 3989 based on discussion in OVSDB meeting"
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / message / TransactBuilder.java
1 /*
2  * Copyright (c) 2013, 2015 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.message;
10
11 import java.util.List;
12
13 import org.opendaylight.ovsdb.lib.jsonrpc.Params;
14 import org.opendaylight.ovsdb.lib.operations.Operation;
15 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
16
17 import com.google.common.collect.Lists;
18
19 public class TransactBuilder implements Params {
20
21     List<Operation> requests = Lists.newArrayList();
22     DatabaseSchema dbSchema;
23     public TransactBuilder(DatabaseSchema dbSchema) {
24         this.dbSchema = dbSchema;
25     }
26
27     public List<Operation> getRequests() {
28         return requests;
29     }
30
31     @Override
32     public List<Object> params() {
33         List<Object> lists = Lists.newArrayList((Object)dbSchema.getName());
34         lists.addAll(requests);
35         return lists;
36     }
37
38     public void addOperations(List<Operation> operation) {
39         requests.addAll(operation);
40     }
41
42     public void addOperation(Operation operation) {
43         requests.add(operation);
44     }
45 }