blob: 676361521f77e65bb7cbfb299a2fea20c4f1b0eb [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.device.impl;
Madan Jampani5009cfb2014-10-08 11:21:07 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.DeviceId;
19import org.onosproject.store.Timestamp;
Madan Jampani5009cfb2014-10-08 11:21:07 -070020
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070021import com.google.common.base.MoreObjects;
22
Madan Jampani5009cfb2014-10-08 11:21:07 -070023/**
24 * Information published by GossipDeviceStore to notify peers of a device
25 * going offline.
26 */
Palash Kala6c526062018-04-03 18:25:11 +090027public class InternalDeviceStatusChangeEvent {
Madan Jampani5009cfb2014-10-08 11:21:07 -070028
29 private final DeviceId deviceId;
30 private final Timestamp timestamp;
Palash Kala6c526062018-04-03 18:25:11 +090031 private final Boolean available;
Madan Jampani5009cfb2014-10-08 11:21:07 -070032
33 /**
Palash Kala6c526062018-04-03 18:25:11 +090034 * Creates a InternalDeviceStatusChangeEvent.
35 * @param deviceId identifier of device.
36 * @param timestamp timestamp of when the device status is changed.
37 * @param available device status is available or not.
Madan Jampani5009cfb2014-10-08 11:21:07 -070038 */
Palash Kala6c526062018-04-03 18:25:11 +090039 public InternalDeviceStatusChangeEvent(DeviceId deviceId, Timestamp timestamp, Boolean available) {
Madan Jampani5009cfb2014-10-08 11:21:07 -070040 this.deviceId = deviceId;
41 this.timestamp = timestamp;
Palash Kala6c526062018-04-03 18:25:11 +090042 this.available = available;
Madan Jampani5009cfb2014-10-08 11:21:07 -070043 }
44
45 public DeviceId deviceId() {
46 return deviceId;
47 }
48
49 public Timestamp timestamp() {
50 return timestamp;
51 }
52
Palash Kala6c526062018-04-03 18:25:11 +090053 public Boolean available() {
54 return available;
55 }
56
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070057 @Override
58 public String toString() {
59 return MoreObjects.toStringHelper(getClass())
60 .add("deviceId", deviceId)
61 .add("timestamp", timestamp)
Palash Kala6c526062018-04-03 18:25:11 +090062 .add("available", available)
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070063 .toString();
64 }
65
Madan Jampani5009cfb2014-10-08 11:21:07 -070066 // for serializer
67 @SuppressWarnings("unused")
Palash Kala6c526062018-04-03 18:25:11 +090068 private InternalDeviceStatusChangeEvent() {
Madan Jampani5009cfb2014-10-08 11:21:07 -070069 deviceId = null;
70 timestamp = null;
Palash Kala6c526062018-04-03 18:25:11 +090071 available = null;
Madan Jampani5009cfb2014-10-08 11:21:07 -070072 }
73}