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