Thomas Vachuska | 4844808 | 2016-02-19 22:14:54 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Thomas Vachuska | 4844808 | 2016-02-19 22:14:54 -0800 | [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 | */ |
| 16 | |
| 17 | package org.onosproject.net.region; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableSet; |
| 20 | import org.onosproject.event.AbstractEvent; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | |
| 23 | import java.util.Set; |
| 24 | |
| 25 | /** |
| 26 | * Describes region event. |
| 27 | */ |
| 28 | public class RegionEvent extends AbstractEvent<RegionEvent.Type, Region> { |
| 29 | |
| 30 | private final Set<DeviceId> deviceIds; |
| 31 | |
| 32 | public enum Type { |
| 33 | /** |
| 34 | * Signifies that a new region was created. |
| 35 | */ |
| 36 | REGION_ADDED, |
| 37 | |
| 38 | /** |
Victor Silva | 066aaa9 | 2016-09-20 11:54:31 -0300 | [diff] [blame] | 39 | * Signifies that a region was removed. |
Thomas Vachuska | 4844808 | 2016-02-19 22:14:54 -0800 | [diff] [blame] | 40 | */ |
| 41 | REGION_REMOVED, |
| 42 | |
| 43 | /** |
Victor Silva | 066aaa9 | 2016-09-20 11:54:31 -0300 | [diff] [blame] | 44 | * Signifies that a region was updated. |
Thomas Vachuska | 4844808 | 2016-02-19 22:14:54 -0800 | [diff] [blame] | 45 | */ |
| 46 | REGION_UPDATED, |
| 47 | |
| 48 | /** |
| 49 | * Signifies that a region device membership has changed. |
| 50 | */ |
| 51 | REGION_MEMBERSHIP_CHANGED |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Creates an event of a given type and for the specified region and the |
| 56 | * current time. |
| 57 | * |
| 58 | * @param type device event type |
| 59 | * @param region event region subject |
| 60 | */ |
| 61 | public RegionEvent(Type type, Region region) { |
| 62 | this(type, region, null); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Creates an event of a given type and for the specified region, device |
| 67 | * id list and the current time. |
| 68 | * |
| 69 | * @param type device event type |
| 70 | * @param region event region subject |
| 71 | * @param deviceIds optional set of device ids |
| 72 | */ |
| 73 | public RegionEvent(Type type, Region region, Set<DeviceId> deviceIds) { |
| 74 | super(type, region); |
| 75 | this.deviceIds = deviceIds != null ? ImmutableSet.copyOf(deviceIds) : ImmutableSet.of(); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Creates an event of a given type and for the specified device and time. |
| 80 | * |
| 81 | * @param type device event type |
| 82 | * @param region event region subject |
| 83 | * @param deviceIds optional set of device ids |
| 84 | * @param time occurrence time |
| 85 | */ |
| 86 | public RegionEvent(Type type, Region region, Set<DeviceId> deviceIds, long time) { |
| 87 | super(type, region, time); |
| 88 | this.deviceIds = deviceIds != null ? ImmutableSet.copyOf(deviceIds) : ImmutableSet.of(); |
| 89 | } |
| 90 | |
| 91 | } |