blob: 93d9b47410acf09f9900d3357694e22b6de3ab47 [file] [log] [blame]
sangho0c2a3da2016-02-16 13:39:07 +09001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
sangho0c2a3da2016-02-16 13:39:07 +09003 *
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 */
sangho93447f12016-02-24 00:33:22 +090016package org.onosproject.openstackinterface;
sangho0c2a3da2016-02-16 13:39:07 +090017
18import java.util.Objects;
19
20import static com.google.common.base.Preconditions.checkNotNull;
21
22/**
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -070023 * An OpenStack Neutron router interface model.
sangho0c2a3da2016-02-16 13:39:07 +090024 */
25public final class OpenstackRouterInterface {
26 private final String id;
27 private final String tenantId;
28 private final String subnetId;
29 private final String portId;
30
31 private OpenstackRouterInterface(String id, String tenantId,
32 String subnetId, String portId) {
33 this.id = checkNotNull(id);
34 this.tenantId = checkNotNull(tenantId);
35 this.subnetId = checkNotNull(subnetId);
36 this.portId = checkNotNull(portId);
37 }
38
39 /**
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -070040 * Returns router interface ID.
sangho0c2a3da2016-02-16 13:39:07 +090041 *
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -070042 * @return router interface id
sangho0c2a3da2016-02-16 13:39:07 +090043 */
44 public String id() {
45 return id;
46 }
47
48 /**
49 * Returns tenant ID.
50 *
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -070051 * @return tenant id
sangho0c2a3da2016-02-16 13:39:07 +090052 */
53 public String tenantId() {
54 return tenantId;
55 }
56
57 /**
58 * Returns subnet ID.
59 *
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -070060 * @return subnet id
sangho0c2a3da2016-02-16 13:39:07 +090061 */
62 public String subnetId() {
63 return subnetId;
64 }
65
66 /**
67 * Returns port ID.
68 *
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -070069 * @return port id
sangho0c2a3da2016-02-16 13:39:07 +090070 */
71 public String portId() {
72 return portId;
73 }
74
75 @Override
76 public boolean equals(Object o) {
77 if (this == o) {
78 return true;
79 }
80
81 if (o instanceof OpenstackRouterInterface) {
82 OpenstackRouterInterface that = (OpenstackRouterInterface) o;
83
84 return this.id.equals(that.id) &&
85 this.portId.equals(that.portId) &&
86 this.subnetId.equals(that.subnetId) &&
87 this.tenantId.equals(that.tenantId);
88 }
89
90 return false;
91 }
92
93 @Override
94 public int hashCode() {
95 return Objects.hash(id, portId, subnetId, tenantId);
96 }
97
98 /**
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -070099 * Returns OpenStack router interface builder.
100 *
101 * @return openstack router interface builder
102 */
103 public static Builder builder() {
104 return new Builder();
105 }
106
107 /**
108 * An OpenStack Router interface builder class.
sangho0c2a3da2016-02-16 13:39:07 +0900109 */
110 public static final class Builder {
Kyuhwi Choie2b37e32016-02-05 14:04:14 +0900111 private String id;
112 private String tenantId;
113 private String subnetId;
114 private String portId;
sangho0c2a3da2016-02-16 13:39:07 +0900115
Kyuhwi Choie2b37e32016-02-05 14:04:14 +0900116 /**
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -0700117 * Sets router interface ID.
sangho0c2a3da2016-02-16 13:39:07 +0900118 *
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -0700119 * @param id router interface id
120 * @return builder object
sangho0c2a3da2016-02-16 13:39:07 +0900121 */
122 public Builder id(String id) {
123 this.id = id;
124 return this;
125 }
126
127 /**
128 * Sets tenant ID.
129 *
130 * @param tenantId tenant ID
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -0700131 * @return builder object
sangho0c2a3da2016-02-16 13:39:07 +0900132 */
133 public Builder tenantId(String tenantId) {
134 this.tenantId = tenantId;
135 return this;
136 }
137
138 /**
139 * Sets subnet ID.
140 *
141 * @param subnetId subnet ID
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -0700142 * @return builder object
sangho0c2a3da2016-02-16 13:39:07 +0900143 */
144 public Builder subnetId(String subnetId) {
145 this.subnetId = subnetId;
146 return this;
147 }
148
149 /**
150 * Sets port ID.
151 *
152 * @param portId port ID
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -0700153 * @return builder object
sangho0c2a3da2016-02-16 13:39:07 +0900154 */
155 public Builder portId(String portId) {
156 this.portId = portId;
157 return this;
158 }
159
sangho0c2a3da2016-02-16 13:39:07 +0900160 /**
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -0700161 * Builds an OpenStack router interface object.
sangho0c2a3da2016-02-16 13:39:07 +0900162 *
Hyunsun Moonb3eb84d2016-07-27 19:10:52 -0700163 * @return openstack router interface object
sangho0c2a3da2016-02-16 13:39:07 +0900164 */
165 public OpenstackRouterInterface build() {
Kyuhwi Choie2b37e32016-02-05 14:04:14 +0900166 return new OpenstackRouterInterface(checkNotNull(id), checkNotNull(tenantId),
167 checkNotNull(subnetId), checkNotNull(portId));
sangho0c2a3da2016-02-16 13:39:07 +0900168 }
sangho0c2a3da2016-02-16 13:39:07 +0900169 }
170}