blob: 212fd375d04c409dd380eaa5e7cec20c036d3664 [file] [log] [blame]
alshabib6b139b42016-01-12 15:55:53 -08001package org.onosproject.olt.api;
2
3import org.onlab.packet.VlanId;
4import org.onosproject.event.AbstractEvent;
5import org.onosproject.net.DeviceId;
6
7import java.util.Optional;
8
9/**
10 * Describes an access device event.
11 */
12public class AccessDeviceEvent extends AbstractEvent<AccessDeviceEvent.Type, DeviceId> {
13
14 private final Optional<VlanId> sVlan;
15 private final Optional<VlanId> cVlan;
16
17 public enum Type {
18 /**
19 * A subscriber was registered and provisioned.
20 */
21 SUBSCRIBER_REGISTERED,
22
23 /**
24 * A subscriber was unregistered and deprovisioned.
25 */
26 SUBSCRIBER_UNREGISTERED,
27
28 /**
29 * An access device connected.
30 */
31 DEVICE_CONNECTED,
32
33 /**
34 * An access device disconnected.
35 */
36 DEVICE_DISCONNECTED
37
38 }
39
40 /**
41 *
42 * Creates an event of a given type and for the specified device,
43 * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
44 * if the event is related to the access device (dis)connection.
45 *
46 * @param type the event type
47 * @param deviceId the device id
48 * @param sVlanId the service vlan
49 * @param cVlanId the customer vlan
50 */
51 public AccessDeviceEvent(Type type, DeviceId deviceId,
52 VlanId sVlanId,
53 VlanId cVlanId) {
54 super(type, deviceId);
55 this.sVlan = Optional.ofNullable(sVlanId);
56 this.cVlan = Optional.ofNullable(cVlanId);
57 }
58
59 /**
60 *
61 * Creates an event of a given type and for the specified device, and timestamp
62 * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
63 * if the event is related to the access device (dis)connection.
64 *
65 * @param type the event type
66 * @param deviceId the device id
67 * @param time a timestamp
68 * @param sVlanId the service vlan
69 * @param cVlanId the customer vlan
70 */
71 protected AccessDeviceEvent(Type type, DeviceId deviceId, long time,
72 VlanId sVlanId,
73 VlanId cVlanId) {
74 super(type, deviceId, time);
75 this.sVlan = Optional.ofNullable(sVlanId);
76 this.cVlan = Optional.ofNullable(cVlanId);
77
78 }
79
80 public Optional<VlanId> sVlanId() {
81 return sVlan;
82 }
83
84 public Optional<VlanId> cVlanId() {
85 return cVlan;
86 }
87
88}