blob: eeb7649fd40636de54695fed527d2af4271dd194 [file] [log] [blame]
Yi Tsenge616d752018-11-27 10:53:27 -08001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package org.onosproject.gnmi.api;
18
19import com.google.common.base.MoreObjects;
20import gnmi.Gnmi.Notification;
21import org.onosproject.net.DeviceId;
22
23/**
24 * Event class for gNMI update.
25 */
26public class GnmiUpdate implements GnmiEventSubject {
27 private DeviceId deviceId;
28 private Notification update;
29 private boolean syncResponse;
30
31 /**
32 * Default constructor.
33 *
34 * @param deviceId the device id for this event
35 * @param update the update for this event
36 * @param syncResponse indicate target has sent all values associated with
37 * the subscription at least once.
38 */
39 public GnmiUpdate(DeviceId deviceId, Notification update, boolean syncResponse) {
40 this.deviceId = deviceId;
41 this.update = update;
42 this.syncResponse = syncResponse;
43 }
44
45 /**
46 * Gets the update data.
47 *
48 * @return the update data
49 */
50 public Notification update() {
51 return update;
52 }
53
54 /**
55 * indicate target has sent all values associated with the subscription at
56 * least once.
57 *
58 * @return true if all value from target has sent
59 */
60 public boolean syncResponse() {
61 return syncResponse;
62 }
63
64 @Override
65 public DeviceId deviceId() {
66 return deviceId;
67 }
68
69 @Override
70 public String toString() {
71 return MoreObjects.toStringHelper(getClass())
72 .add("deviceId", deviceId)
73 .add("syncResponse", syncResponse)
74 .add("update", update)
75 .toString();
76 }
77}