Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -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 | */ |
| 16 | package org.onosproject.incubator.net.virtual; |
| 17 | |
| 18 | import org.onosproject.event.AbstractEvent; |
| 19 | |
| 20 | /** |
| 21 | * Describes virtual network event. |
| 22 | */ |
| 23 | public class VirtualNetworkEvent extends AbstractEvent<VirtualNetworkEvent.Type, NetworkId> { |
| 24 | |
| 25 | /** |
| 26 | * Type of virtual network events. |
| 27 | */ |
| 28 | public enum Type { |
| 29 | /** |
| 30 | * Signifies that a new tenant identifier was registered. |
| 31 | */ |
| 32 | TENANT_REGISTERED, |
| 33 | /** |
| 34 | * Signifies that a tenant identifier was unregistered. |
| 35 | */ |
| 36 | TENANT_UNREGISTERED, |
| 37 | /** |
| 38 | * Signifies that a new virtual network was added. |
| 39 | */ |
| 40 | NETWORK_ADDED, |
| 41 | /** |
| 42 | * Signifies that a virtual network was updated. |
| 43 | */ |
| 44 | NETWORK_UPDATED, |
| 45 | /** |
| 46 | * Signifies that a virtual network was removed. |
| 47 | */ |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 48 | NETWORK_REMOVED, |
| 49 | /** |
| 50 | * Signifies that a new virtual network device was added. |
| 51 | */ |
| 52 | VIRTUAL_DEVICE_ADDED, |
| 53 | /** |
| 54 | * Signifies that a virtual network device was updated. |
| 55 | */ |
| 56 | VIRTUAL_DEVICE_UPDATED, |
| 57 | /** |
| 58 | * Signifies that a virtual network device was removed. |
| 59 | */ |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 60 | VIRTUAL_DEVICE_REMOVED, |
| 61 | /** |
| 62 | * Signifies that a new virtual network port was added. |
| 63 | */ |
| 64 | VIRTUAL_PORT_ADDED, |
| 65 | /** |
| 66 | * Signifies that a virtual network port was updated. |
| 67 | */ |
| 68 | VIRTUAL_PORT_UPDATED, |
| 69 | /** |
| 70 | * Signifies that a virtual network port was removed. |
| 71 | */ |
| 72 | VIRTUAL_PORT_REMOVED |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 75 | private final VirtualDevice virtualDevice; |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 76 | private final VirtualPort virtualPort; |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 77 | |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 78 | /** |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 79 | * Creates an event of a given type and for the specified subject. |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 80 | * |
| 81 | * @param type event type |
| 82 | * @param subject event subject |
| 83 | */ |
| 84 | public VirtualNetworkEvent(Type type, NetworkId subject) { |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 85 | this(type, subject, null, null); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Creates an event of a given type and for the specified subject and the |
| 90 | * virtual device. |
| 91 | * |
| 92 | * @param type event type |
| 93 | * @param subject event subject |
| 94 | * @param virtualDevice virtual device |
| 95 | */ |
| 96 | public VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice) { |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 97 | this(type, subject, virtualDevice, null); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Creates an event of a given type and for the specified subject and the |
| 102 | * virtual port. |
| 103 | * |
| 104 | * @param type event type |
| 105 | * @param subject event subject |
| 106 | * @param virtualPort virtual port |
| 107 | */ |
| 108 | public VirtualNetworkEvent(Type type, NetworkId subject, VirtualPort virtualPort) { |
| 109 | this(type, subject, null, virtualPort); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Creates an event of a given type and for the specified subject, virtual device and |
| 114 | * virtual port. |
| 115 | * |
| 116 | * @param type event type |
| 117 | * @param subject event subject |
| 118 | * @param virtualDevice virtual device |
| 119 | * @param virtualPort virtual port |
| 120 | */ |
| 121 | private VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice, |
| 122 | VirtualPort virtualPort) { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 123 | super(type, subject); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 124 | this.virtualDevice = virtualDevice; |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 125 | this.virtualPort = virtualPort; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Creates an event of a given type and for the specified subject and time. |
| 130 | * |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 131 | * @param type event type |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 132 | * @param subject event subject |
| 133 | * @param time occurrence time |
| 134 | */ |
| 135 | public VirtualNetworkEvent(Type type, NetworkId subject, long time) { |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 136 | this(type, subject, null, null, time); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Creates an event of a given type and for the specified subject, virtual device and time. |
| 141 | * |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 142 | * @param type event type |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 143 | * @param subject event subject |
| 144 | * @param virtualDevice virtual device |
| 145 | * @param time occurrence time |
| 146 | */ |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 147 | public VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice, |
| 148 | long time) { |
| 149 | this(type, subject, virtualDevice, null, time); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Creates an event of a given type and for the specified subject, virtual port and time. |
| 154 | * |
| 155 | * @param type device event type |
| 156 | * @param subject event subject |
| 157 | * @param virtualPort virtual port |
| 158 | * @param time occurrence time |
| 159 | */ |
| 160 | public VirtualNetworkEvent(Type type, NetworkId subject, VirtualPort virtualPort, |
| 161 | long time) { |
| 162 | this(type, subject, null, virtualPort, time); |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Creates an event of a given type and for the specified subject, virtual device, |
| 167 | * virtual port and time. |
| 168 | * |
| 169 | * @param type device event type |
| 170 | * @param subject event subject |
| 171 | * @param virtualDevice virtual device |
| 172 | * @param virtualPort virtual port |
| 173 | * @param time occurrence time |
| 174 | */ |
| 175 | private VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice, |
| 176 | VirtualPort virtualPort, long time) { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 177 | super(type, subject, time); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 178 | this.virtualDevice = virtualDevice; |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 179 | this.virtualPort = virtualPort; |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Returns virtual device affected by event - may be null (for events relating to |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 184 | * tenants, virtual networks and virtual ports). |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 185 | * |
| 186 | * @return virtual device |
| 187 | */ |
| 188 | public VirtualDevice virtualDevice() { |
| 189 | return virtualDevice; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 190 | } |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame^] | 191 | |
| 192 | /** |
| 193 | * Returns virtual port affected by event - may be null (for events relating to |
| 194 | * tenants, virtual networks and virtual devices). |
| 195 | * |
| 196 | * @return virtual port |
| 197 | */ |
| 198 | public VirtualPort virtualPort() { |
| 199 | return virtualPort; |
| 200 | } |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 201 | } |