Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.device.impl; |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.net.DeviceId; |
| 19 | import org.onosproject.store.Timestamp; |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 20 | |
Yuta HIGUCHI | 9ee60f6 | 2014-10-09 10:00:01 -0700 | [diff] [blame] | 21 | import com.google.common.base.MoreObjects; |
| 22 | |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Information published by GossipDeviceStore to notify peers of a device |
| 25 | * going offline. |
| 26 | */ |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 27 | public class InternalDeviceStatusChangeEvent { |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 28 | |
| 29 | private final DeviceId deviceId; |
| 30 | private final Timestamp timestamp; |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 31 | private final Boolean available; |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 34 | * 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 Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 38 | */ |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 39 | public InternalDeviceStatusChangeEvent(DeviceId deviceId, Timestamp timestamp, Boolean available) { |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 40 | this.deviceId = deviceId; |
| 41 | this.timestamp = timestamp; |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 42 | this.available = available; |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | public DeviceId deviceId() { |
| 46 | return deviceId; |
| 47 | } |
| 48 | |
| 49 | public Timestamp timestamp() { |
| 50 | return timestamp; |
| 51 | } |
| 52 | |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 53 | public Boolean available() { |
| 54 | return available; |
| 55 | } |
| 56 | |
Yuta HIGUCHI | 9ee60f6 | 2014-10-09 10:00:01 -0700 | [diff] [blame] | 57 | @Override |
| 58 | public String toString() { |
| 59 | return MoreObjects.toStringHelper(getClass()) |
| 60 | .add("deviceId", deviceId) |
| 61 | .add("timestamp", timestamp) |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 62 | .add("available", available) |
Yuta HIGUCHI | 9ee60f6 | 2014-10-09 10:00:01 -0700 | [diff] [blame] | 63 | .toString(); |
| 64 | } |
| 65 | |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 66 | // for serializer |
| 67 | @SuppressWarnings("unused") |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 68 | private InternalDeviceStatusChangeEvent() { |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 69 | deviceId = null; |
| 70 | timestamp = null; |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 71 | available = null; |
Madan Jampani | 5009cfb | 2014-10-08 11:21:07 -0700 | [diff] [blame] | 72 | } |
| 73 | } |