Kyuhwi Choi | c5b33ea | 2016-04-26 11:45:32 +0900 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-present 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 | package org.onosproject.scalablegateway; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableList; |
| 19 | import org.onlab.packet.Ip4Address; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | |
| 22 | import java.util.List; |
| 23 | |
| 24 | import static com.google.common.base.Preconditions.checkNotNull; |
| 25 | |
| 26 | /** |
| 27 | * Represents SONA GatewayNode information. |
| 28 | */ |
| 29 | public final class GatewayNode { |
| 30 | private final DeviceId gatewayDeviceId; |
| 31 | private final List<String> gatewayExternalInterfaceNames; |
| 32 | private final Ip4Address dataIpAddress; |
| 33 | |
| 34 | private GatewayNode(DeviceId gatewayDeviceId, List<String> gatewayExternalInterfaceNames, |
| 35 | Ip4Address dataIpAddress) { |
| 36 | this.gatewayDeviceId = gatewayDeviceId; |
| 37 | this.gatewayExternalInterfaceNames = gatewayExternalInterfaceNames; |
| 38 | this.dataIpAddress = dataIpAddress; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the device id of gateway node. |
| 43 | * |
| 44 | * @return The device id of gateway node |
| 45 | */ |
| 46 | public DeviceId getGatewayDeviceId() { |
| 47 | return gatewayDeviceId; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns the list of gateway`s interface names. |
| 52 | * |
| 53 | * @return The list of interface names |
| 54 | */ |
| 55 | public List<String> getGatewayExternalInterfaceNames() { |
| 56 | return ImmutableList.copyOf(gatewayExternalInterfaceNames); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns the data ip address of gateway node. |
| 61 | * |
| 62 | * @return The data ip address of gateway node |
| 63 | */ |
| 64 | public Ip4Address getDataIpAddress() { |
| 65 | return dataIpAddress; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * GatewayNode Builder class. |
| 70 | */ |
| 71 | public static final class Builder { |
| 72 | |
| 73 | private DeviceId gatewayDeviceId; |
| 74 | private List<String> gatewayExternalInterfaceNames; |
| 75 | private Ip4Address dataIpAddress; |
| 76 | |
| 77 | /** |
| 78 | * Sets the device id of gateway node. |
| 79 | * |
| 80 | * @param deviceId The device id of gateway node |
| 81 | * @return Builder object |
| 82 | */ |
| 83 | public Builder gatewayDeviceId(DeviceId deviceId) { |
| 84 | this.gatewayDeviceId = deviceId; |
| 85 | return this; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Sets the list of gateway`s interface names. |
| 90 | * |
| 91 | * @param names The list of gateway`s interface name |
| 92 | * @return Builder object |
| 93 | */ |
| 94 | public Builder gatewayExternalInterfaceNames(List<String> names) { |
| 95 | this.gatewayExternalInterfaceNames = names; |
| 96 | return this; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Sets the ip address of gateway node for data plain. |
| 101 | * |
| 102 | * @param address The ip address of gateway node |
| 103 | * @return Builder object |
| 104 | */ |
| 105 | public Builder dataIpAddress(Ip4Address address) { |
| 106 | this.dataIpAddress = address; |
| 107 | return this; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Builds a GatewayNode object. |
| 112 | * |
| 113 | * @return GatewayNode object |
| 114 | */ |
| 115 | public GatewayNode build() { |
| 116 | return new GatewayNode(checkNotNull(gatewayDeviceId), checkNotNull(gatewayExternalInterfaceNames), |
| 117 | checkNotNull(dataIpAddress)); |
| 118 | } |
| 119 | } |
| 120 | } |