blob: 9c710848f2581584a1ac0f5d07e2bdec34bf1164 [file] [log] [blame]
Brian O'Connor5dcf5782016-04-09 02:13:23 -07001/*
Brian O'Connord6a135a2017-08-03 22:46:05 -07002 * Copyright 2016-present Open Networking Foundation
Brian O'Connor5dcf5782016-04-09 02:13:23 -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 */
alshabib36a4d732016-06-01 16:03:59 -070016package org.opencord.olt;
alshabib8e4fd2f2016-01-12 15:55:53 -080017
18import org.onlab.packet.VlanId;
19import org.onosproject.event.AbstractEvent;
20import org.onosproject.net.DeviceId;
21
22import java.util.Optional;
23
24/**
25 * Describes an access device event.
26 */
27public class AccessDeviceEvent extends AbstractEvent<AccessDeviceEvent.Type, DeviceId> {
28
29 private final Optional<VlanId> sVlan;
30 private final Optional<VlanId> cVlan;
31
32 public enum Type {
33 /**
34 * A subscriber was registered and provisioned.
35 */
36 SUBSCRIBER_REGISTERED,
37
38 /**
39 * A subscriber was unregistered and deprovisioned.
40 */
41 SUBSCRIBER_UNREGISTERED,
42
43 /**
44 * An access device connected.
45 */
46 DEVICE_CONNECTED,
47
48 /**
49 * An access device disconnected.
50 */
51 DEVICE_DISCONNECTED
52
53 }
54
55 /**
56 *
57 * Creates an event of a given type and for the specified device,
58 * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
59 * if the event is related to the access device (dis)connection.
60 *
61 * @param type the event type
62 * @param deviceId the device id
63 * @param sVlanId the service vlan
64 * @param cVlanId the customer vlan
65 */
66 public AccessDeviceEvent(Type type, DeviceId deviceId,
67 VlanId sVlanId,
68 VlanId cVlanId) {
69 super(type, deviceId);
70 this.sVlan = Optional.ofNullable(sVlanId);
71 this.cVlan = Optional.ofNullable(cVlanId);
72 }
73
74 /**
75 *
76 * Creates an event of a given type and for the specified device, and timestamp
77 * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
78 * if the event is related to the access device (dis)connection.
79 *
80 * @param type the event type
81 * @param deviceId the device id
82 * @param time a timestamp
83 * @param sVlanId the service vlan
84 * @param cVlanId the customer vlan
85 */
86 protected AccessDeviceEvent(Type type, DeviceId deviceId, long time,
87 VlanId sVlanId,
88 VlanId cVlanId) {
89 super(type, deviceId, time);
90 this.sVlan = Optional.ofNullable(sVlanId);
91 this.cVlan = Optional.ofNullable(cVlanId);
92
93 }
94
95 public Optional<VlanId> sVlanId() {
96 return sVlan;
97 }
98
99 public Optional<VlanId> cVlanId() {
100 return cVlan;
101 }
102
103}