2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onosproject.ovsdb.rfc.message;
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 import static com.google.common.base.Preconditions.checkNotNull;
21 import java.util.Objects;
23 import org.onosproject.ovsdb.rfc.notation.json.UpdateNotificationConverter;
25 import com.fasterxml.jackson.databind.JsonNode;
26 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
29 * The "update" notification is sent by the server to the client to report
30 * changes in tables that are being monitored following a "monitor" request. The
31 * "params" of the result JsonNode.
33 @JsonDeserialize(converter = UpdateNotificationConverter.class)
34 public final class UpdateNotification {
35 private final Object jsonValue;
36 private final JsonNode tbUpdatesJsonNode;
39 * Constructs a UpdateNotification object.
40 * @param jsonValue the "json-value" in "params" of the result JsonNode
41 * @param tbUpdatesJsonNode the "table-updates" in "params" of the result JsonNode
43 public UpdateNotification(Object jsonValue, JsonNode tbUpdatesJsonNode) {
44 checkNotNull(jsonValue, "jsonValue cannot be null");
45 checkNotNull(tbUpdatesJsonNode, "tablebUpdates JsonNode cannot be null");
46 this.jsonValue = jsonValue;
47 this.tbUpdatesJsonNode = tbUpdatesJsonNode;
54 public Object jsonValue() {
59 * Return tbUpdatesJsonNode.
60 * @return tbUpdatesJsonNode
62 public JsonNode tbUpdatesJsonNode() {
63 return tbUpdatesJsonNode;
67 public int hashCode() {
68 return Objects.hash(jsonValue, tbUpdatesJsonNode);
72 public boolean equals(Object obj) {
76 if (obj instanceof UpdateNotification) {
77 final UpdateNotification other = (UpdateNotification) obj;
78 return Objects.equals(this.jsonValue, other.jsonValue)
79 && Objects.equals(this.tbUpdatesJsonNode,
80 other.tbUpdatesJsonNode);
86 public String toString() {
87 return toStringHelper(this).add("jsonValue", jsonValue)
88 .add("tbUpdatesJsonNode", tbUpdatesJsonNode).toString();