blob: 52a611415fa7a00cd61d6b414dd67b9798d3eab5 [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;
Kyuhwi Choie2b37e32016-02-05 14:04:14 +090019import static com.google.common.base.Preconditions.checkNotNull;
sangho0c2a3da2016-02-16 13:39:07 +090020
21/**
22 * An Openstack Neutron Router Model.
23 */
24public final class OpenstackRouter {
25
26 public enum RouterStatus {
27 UP,
28 DOWN,
29 ACTIVE,
30 }
31
32 private final String tenantId;
33 private final String id;
34 private final String name;
Kyuhwi Choie2b37e32016-02-05 14:04:14 +090035 private RouterStatus status;
36 private boolean adminStateUp;
37 private OpenstackExternalGateway gatewayExternalInfo;
sangho0c2a3da2016-02-16 13:39:07 +090038
39 private OpenstackRouter(String id, String tenantId, String name, RouterStatus status,
40 boolean adminStateUp, OpenstackExternalGateway gatewayExternalInfo) {
41 this.id = id;
42 this.tenantId = tenantId;
43 this.name = name;
44 this.status = status;
45 this.adminStateUp = adminStateUp;
46 this.gatewayExternalInfo = gatewayExternalInfo;
47
48 }
49
50 /**
51 * Returns tenant ID.
52 *
53 * @return tenant ID
54 */
55 public String tenantId() {
56 return tenantId;
57 }
58
59 /**
60 * Returns router ID.
61 *
62 * @return router ID
63 */
64 public String id() {
65 return id;
66 }
67
68 /**
69 * Returns router name.
70 *
71 * @return router name
72 */
73 public String name() {
74 return name;
75 }
76
77 /**
78 * Returns router status.
79 *
80 * @return router stauts
81 */
82 public RouterStatus status() {
83 return status;
84 }
85
86 /**
87 * Returns whether admin state up or not.
88 *
89 * @return true if admin state up, false otherwise
90 */
91 public boolean adminStateUp() {
92 return adminStateUp;
93 }
94
95 /**
96 * Returns external gateway information.
97 *
98 * @return external gateway information
99 */
100 public OpenstackExternalGateway gatewayExternalInfo() {
101 return gatewayExternalInfo;
102 }
103
104 @Override
105 public boolean equals(Object o) {
106 if (this == o) {
107 return true;
108 }
109
110 if (o instanceof OpenstackRouter) {
111 OpenstackRouter that = (OpenstackRouter) o;
112
113 return this.adminStateUp == that.adminStateUp &&
114 this.gatewayExternalInfo.equals(that.gatewayExternalInfo) &&
115 this.id.equals(that.id) &&
116 this.name.equals(that.name) &&
117 this.status.equals(that.status) &&
118 this.tenantId.equals(that.tenantId);
119 }
120
121 return false;
122 }
123
124 @Override
125 public int hashCode() {
126 return Objects.hash(adminStateUp, gatewayExternalInfo, id, name, status, tenantId);
127 }
128
129 /**
130 * An Openstack Router Builder class.
131 */
132 public static final class Builder {
133
134 private String tenantId;
135 private String id;
136 private String name;
137 private RouterStatus status;
138 private Boolean adminStateUp;
139 private OpenstackExternalGateway gatewayExternalInfo;
140
141 /**
142 * Sets router ID.
143 *
144 * @param id router ID
145 * @return Builder object
146 */
147 public Builder id(String id) {
148 this.id = id;
149 return this;
150 }
151
152 /**
153 * Sets router name.
154 *
155 * @param name router name
156 * @return Builder object
157 */
158 public Builder name(String name) {
159 this.name = name;
160 return this;
161 }
162
163 /**
164 * Sets router status.
165 *
166 * @param status router status
167 * @return Builder object
168 */
169 public Builder status(RouterStatus status) {
170 this.status = status;
171 return this;
172 }
173
174 /**
175 * Sets tenant ID.
176 *
177 * @param tenantId Tenant ID
178 * @return Builder object
179 */
180 public Builder tenantId(String tenantId) {
181 this.tenantId = tenantId;
182 return this;
183 }
184
185 /**
186 * Sets whether admin state up or not.
187 *
188 * @param adminStateUp true if admin state is up, false otherwise
189 * @return Builder object
190 */
191 public Builder adminStateUp(boolean adminStateUp) {
192 this.adminStateUp = adminStateUp;
193 return this;
194 }
195
196 /**
197 * Sets external gateway information.
198 *
199 * @param gatewayExternalInfo external gateway information
200 * @return Builder object
201 */
202 public Builder gatewayExternalInfo(OpenstackExternalGateway gatewayExternalInfo) {
203 this.gatewayExternalInfo = gatewayExternalInfo;
204 return this;
205 }
206
207 /**
208 * Builds an OpenstackRouter object.
209 *
210 * @return OpenstasckRouter object
211 */
212 public OpenstackRouter build() {
Kyuhwi Choie2b37e32016-02-05 14:04:14 +0900213 return new OpenstackRouter(checkNotNull(id), checkNotNull(tenantId), name, checkNotNull(status),
214 checkNotNull(adminStateUp), gatewayExternalInfo);
sangho0c2a3da2016-02-16 13:39:07 +0900215 }
216 }
217
218
219}