Added more ignorable files to .gitignore
[ovsdb.git] / ovsdb / src / main / java / org / opendaylight / ovsdb / lib / operations / Update.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.collect.Maps;
17 import org.opendaylight.ovsdb.lib.notation.Condition;
18 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
19 import org.opendaylight.ovsdb.lib.schema.TableSchema;
20
21 import java.util.List;
22 import java.util.Map;
23
24 public class Update<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
25
26     Map<String, Object> row = Maps.newHashMap();
27     String uuid;
28     //Where where;
29     List<Condition> where = Lists.newArrayList();
30
31     private String uuidName;
32
33     public Update(TableSchema<E> schema) {
34         super(schema, "update");
35     }
36
37     public Update<E> on(TableSchema schema){
38         return this;
39     }
40
41     public <T extends TableSchema<T>, D> Update<E> set(ColumnSchema<T, D> columnSchema, D value) {
42         columnSchema.validate(value);
43         this.row.put(columnSchema.getName(), value);
44         return this;
45     }
46
47     public Where where(Condition condition) {
48         return new Where(this);
49     }
50
51     public String getUuid() {
52         return uuid;
53     }
54
55     public void setUuid(String uuid) {
56         this.uuid = uuid;
57     }
58
59     public String getUuidName() {
60         return uuidName;
61     }
62
63     public void setUuidName(String uuidName) {
64         this.uuidName = uuidName;
65     }
66
67     public Map<String, Object> getRow() {
68         return row;
69     }
70
71     public void setRow(Map<String, Object> row) {
72         this.row = row;
73     }
74
75     @Override
76     public void addCondition(Condition condition) {
77         this.where.add(condition);
78     }
79
80     public List<Condition> getWhere() {
81         return where;
82     }
83
84     public void setWhere(List<Condition> where) {
85         this.where = where;
86     }
87 }