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