Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
alshabib | 03adb49 | 2016-02-01 17:25:00 -0800 | [diff] [blame] | 17 | package org.onosproject.olt; |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 18 | |
| 19 | import org.onlab.packet.VlanId; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | |
Jonathan Hart | 4832784 | 2015-11-10 16:09:22 -0800 | [diff] [blame] | 23 | import java.util.Optional; |
| 24 | |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 25 | import static com.google.common.base.Preconditions.checkNotNull; |
| 26 | |
| 27 | /** |
| 28 | * Information about an access device. |
| 29 | */ |
| 30 | public 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 Hart | 4832784 | 2015-11-10 16:09:22 -0800 | [diff] [blame] | 38 | private final Optional<VlanId> defaultVlan; |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Class constructor. |
| 42 | * |
| 43 | * @param deviceId access device ID |
| 44 | * @param uplink uplink port number |
| 45 | * @param vlan device VLAN ID |
Jian Li | dfba739 | 2016-01-22 16:46:58 -0800 | [diff] [blame] | 46 | * @param defaultVlan default device VLAN ID |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 47 | */ |
Jonathan Hart | 4832784 | 2015-11-10 16:09:22 -0800 | [diff] [blame] | 48 | public AccessDeviceData(DeviceId deviceId, PortNumber uplink, VlanId vlan, |
| 49 | Optional<VlanId> defaultVlan) { |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 50 | this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING); |
| 51 | this.uplink = checkNotNull(uplink, UPLINK_MISSING); |
| 52 | this.vlan = checkNotNull(vlan, VLAN_MISSING); |
Jonathan Hart | 4832784 | 2015-11-10 16:09:22 -0800 | [diff] [blame] | 53 | this.defaultVlan = checkNotNull(defaultVlan); |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 54 | } |
| 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 Hart | 4832784 | 2015-11-10 16:09:22 -0800 | [diff] [blame] | 77 | * @return VLAN ID |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 78 | */ |
| 79 | public VlanId vlan() { |
| 80 | return vlan; |
| 81 | } |
Jonathan Hart | 4832784 | 2015-11-10 16:09:22 -0800 | [diff] [blame] | 82 | |
| 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 Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 91 | } |