blob: 0092cd3c3dac1f9e810025ce5c9ec63830095598 [file] [log] [blame]
Jonathan Harte533a422015-10-20 17:31:24 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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
alshabib000b6fc2016-02-01 17:25:00 -080017package org.onosproject.olt;
Jonathan Harte533a422015-10-20 17:31:24 -070018
19import org.onlab.packet.VlanId;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.PortNumber;
22
Jonathan Hart52998382015-11-10 16:09:22 -080023import java.util.Optional;
24
Jonathan Harte533a422015-10-20 17:31:24 -070025import static com.google.common.base.Preconditions.checkNotNull;
26
27/**
28 * Information about an access device.
29 */
30public class AccessDeviceData {
31 private static final String DEVICE_ID_MISSING = "Device ID cannot be null";
32 private static final String UPLINK_MISSING = "Uplink cannot be null";
33 private static final String VLAN_MISSING = "VLAN ID cannot be null";
34
35 private final DeviceId deviceId;
36 private final PortNumber uplink;
37 private final VlanId vlan;
Jonathan Hart52998382015-11-10 16:09:22 -080038 private final Optional<VlanId> defaultVlan;
Jonathan Harte533a422015-10-20 17:31:24 -070039
40 /**
41 * Class constructor.
42 *
43 * @param deviceId access device ID
44 * @param uplink uplink port number
45 * @param vlan device VLAN ID
Jian Lid8bca082016-01-22 16:46:58 -080046 * @param defaultVlan default device VLAN ID
Jonathan Harte533a422015-10-20 17:31:24 -070047 */
Jonathan Hart52998382015-11-10 16:09:22 -080048 public AccessDeviceData(DeviceId deviceId, PortNumber uplink, VlanId vlan,
49 Optional<VlanId> defaultVlan) {
Jonathan Harte533a422015-10-20 17:31:24 -070050 this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING);
51 this.uplink = checkNotNull(uplink, UPLINK_MISSING);
52 this.vlan = checkNotNull(vlan, VLAN_MISSING);
Jonathan Hart52998382015-11-10 16:09:22 -080053 this.defaultVlan = checkNotNull(defaultVlan);
Jonathan Harte533a422015-10-20 17:31:24 -070054 }
55
56 /**
57 * Retrieves the access device ID.
58 *
59 * @return device ID
60 */
61 public DeviceId deviceId() {
62 return deviceId;
63 }
64
65 /**
66 * Retrieves the uplink port number.
67 *
68 * @return port number
69 */
70 public PortNumber uplink() {
71 return uplink;
72 }
73
74 /**
75 * Retrieves the VLAN ID assigned to the device.
76 *
Jonathan Hart52998382015-11-10 16:09:22 -080077 * @return VLAN ID
Jonathan Harte533a422015-10-20 17:31:24 -070078 */
79 public VlanId vlan() {
80 return vlan;
81 }
Jonathan Hart52998382015-11-10 16:09:22 -080082
83 /**
84 * Retrieves the default VLAN ID that will be used for this device.
85 *
86 * @return default VLAN ID
87 */
88 public Optional<VlanId> defaultVlan() {
89 return defaultVlan;
90 }
Jonathan Harte533a422015-10-20 17:31:24 -070091}