Merge "Changed lookup of Controller IP to the following: - Start with OVSDB config...
[ovsdb.git] / ovsdb / src / main / java / org / opendaylight / ovsdb / lib / message / TableUpdate.java
1 /*
2  * Copyright (C) 2013 EBay Software Foundation
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  * Authors : Ashwin Raveendran, Madhu Venugopal
9  */
10 package org.opendaylight.ovsdb.lib.message;
11
12 import com.fasterxml.jackson.annotation.JsonAnyGetter;
13 import com.fasterxml.jackson.annotation.JsonAnySetter;
14 import com.fasterxml.jackson.annotation.JsonIgnore;
15 import com.fasterxml.jackson.annotation.JsonProperty;
16 import com.google.common.collect.Maps;
17
18 import java.util.Collection;
19 import java.util.Map;
20 import java.util.Set;
21
22 import org.opendaylight.ovsdb.lib.table.internal.Table;
23
24
25 public  class TableUpdate<T extends Table>  {
26     /*This could have been done as a map, but doing so would expose the inner wrapper class in type signature*/
27
28     Map<String, Row<T>> map = Maps.newHashMap();
29
30     @JsonAnyGetter
31     public Row<T> get(String rowId) {
32         return map.get(rowId);
33     }
34
35     @JsonAnySetter
36     public void set(String rowId, Row<T> value) {
37         map.put(rowId, value);
38         value.setId(rowId);
39     }
40
41     public Collection<Row<T>> getRows() {
42         return map.values();
43     }
44
45     @Override
46     public String toString() {
47         return "TableUpdate [map=" + map + "]";
48     }
49
50     public static class Row<T> {
51
52         @JsonIgnore
53         String id;
54
55         @JsonProperty("new")
56         T _new;
57         T old;
58
59         public String getId() {
60             return id;
61         }
62
63         public T getNew() {
64             return _new;
65         }
66
67         public void setNew(T neww) {
68             this._new = neww;
69         }
70
71         public T getOld() {
72             return old;
73         }
74
75         public void setOld(T old) {
76             this.old = old;
77         }
78
79         void setId(String id) {
80             this.id = id;
81         }
82
83         @Override
84         public String toString() {
85             return "Row{" +
86                     "id='" + id + '\'' +
87                     ", _new=" + _new.toString() +
88                     '}';
89         }
90
91     }
92 }