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