blob: dee5f5a7b5331dce32d34ae3c4f331219b12e03b [file] [log] [blame]
Jonathan Hart3e594642015-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
Srikanth Vavilapalli0d21dd12016-01-16 19:21:59 -080017package org.onosproject.olt.impl;
Jonathan Hart3e594642015-10-20 17:31:24 -070018
19import org.onlab.packet.VlanId;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.PortNumber;
22
Jonathan Hart48327842015-11-10 16:09:22 -080023import java.util.Optional;
24
Jonathan Hart3e594642015-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 Hart48327842015-11-10 16:09:22 -080038 private final Optional<VlanId> defaultVlan;
Jonathan Hart3e594642015-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
46 */
Jonathan Hart48327842015-11-10 16:09:22 -080047 public AccessDeviceData(DeviceId deviceId, PortNumber uplink, VlanId vlan,
48 Optional<VlanId> defaultVlan) {
Jonathan Hart3e594642015-10-20 17:31:24 -070049 this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING);
50 this.uplink = checkNotNull(uplink, UPLINK_MISSING);
51 this.vlan = checkNotNull(vlan, VLAN_MISSING);
Jonathan Hart48327842015-11-10 16:09:22 -080052 this.defaultVlan = checkNotNull(defaultVlan);
Jonathan Hart3e594642015-10-20 17:31:24 -070053 }
54
55 /**
56 * Retrieves the access device ID.
57 *
58 * @return device ID
59 */
60 public DeviceId deviceId() {
61 return deviceId;
62 }
63
64 /**
65 * Retrieves the uplink port number.
66 *
67 * @return port number
68 */
69 public PortNumber uplink() {
70 return uplink;
71 }
72
73 /**
74 * Retrieves the VLAN ID assigned to the device.
75 *
Jonathan Hart48327842015-11-10 16:09:22 -080076 * @return VLAN ID
Jonathan Hart3e594642015-10-20 17:31:24 -070077 */
78 public VlanId vlan() {
79 return vlan;
80 }
Jonathan Hart48327842015-11-10 16:09:22 -080081
82 /**
83 * Retrieves the default VLAN ID that will be used for this device.
84 *
85 * @return default VLAN ID
86 */
87 public Optional<VlanId> defaultVlan() {
88 return defaultVlan;
89 }
Jonathan Hart3e594642015-10-20 17:31:24 -070090}