blob: c02c1ec8ce52b004df68f83bd345571c7c835efb [file] [log] [blame]
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +09001/*
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 Moon71701292016-05-09 12:00:54 -070016package org.onosproject.scalablegateway.api;
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090017
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090018import org.onlab.packet.Ip4Address;
19import org.onosproject.net.DeviceId;
20
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090021import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * Represents SONA GatewayNode information.
25 */
26public final class GatewayNode {
27 private final DeviceId gatewayDeviceId;
Kyuhwi Choi176c83d2016-07-14 11:39:37 +090028 private final String gatewayExternalInterfaceName;
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090029 private final Ip4Address dataIpAddress;
30
Kyuhwi Choi176c83d2016-07-14 11:39:37 +090031 private GatewayNode(DeviceId gatewayDeviceId, String gatewayExternalInterfaceName,
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090032 Ip4Address dataIpAddress) {
33 this.gatewayDeviceId = gatewayDeviceId;
Kyuhwi Choi176c83d2016-07-14 11:39:37 +090034 this.gatewayExternalInterfaceName = gatewayExternalInterfaceName;
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090035 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 Choi176c83d2016-07-14 11:39:37 +090048 * Returns the gateway`s interface name.
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090049 *
Kyuhwi Choi176c83d2016-07-14 11:39:37 +090050 * @return The gateway`s interface name
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090051 */
Kyuhwi Choi176c83d2016-07-14 11:39:37 +090052 public String getGatewayExternalInterfaceName() {
53 return gatewayExternalInterfaceName;
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090054 }
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 Choi92d9ea42016-06-13 17:28:00 +090066 * Returns GatewayNode builder object.
67 *
68 * @return GatewayNode builder
69 */
70 public static GatewayNode.Builder builder() {
71 return new Builder();
72 }
73
74 /**
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090075 * GatewayNode Builder class.
76 */
77 public static final class Builder {
78
79 private DeviceId gatewayDeviceId;
Kyuhwi Choi176c83d2016-07-14 11:39:37 +090080 private String gatewayExternalInterfaceName;
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090081 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 Choi176c83d2016-07-14 11:39:37 +090095 * Sets the gateway`s interface name.
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090096 *
Kyuhwi Choi176c83d2016-07-14 11:39:37 +090097 * @param name The gateway`s interface name
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +090098 * @return Builder object
99 */
Kyuhwi Choi176c83d2016-07-14 11:39:37 +0900100 public Builder gatewayExternalInterfaceName(String name) {
101 this.gatewayExternalInterfaceName = name;
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +0900102 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 Choi176c83d2016-07-14 11:39:37 +0900122 return new GatewayNode(checkNotNull(gatewayDeviceId), checkNotNull(gatewayExternalInterfaceName),
Kyuhwi Choic5b33ea2016-04-26 11:45:32 +0900123 checkNotNull(dataIpAddress));
124 }
125 }
126}