blob: 39d783e32c380260d96db90fbe388df0578aee42 [file] [log] [blame]
danielbb83ebc2015-10-29 15:13:06 +09001/*
2 * Copyright 2015 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.openstackswitching;
17
18import static com.google.common.base.Preconditions.checkNotNull;
19
20/**
21 * Represents the subnet information given by Neutron.
22 *
23 */
24public final class OpenstackSubnet {
25 private String name;
26 private boolean enableHhcp;
27 private String networkId;
28 private String tenantId;
29 private String dnsNameservers;
30 private String gatewayIp;
31 private String cidr;
32 private String id;
33
34 private OpenstackSubnet(String name, boolean enableHhcp, String networkId,
35 String tenantId, String dnsNameservers, String gatewayIp,
36 String cidr, String id) {
37 this.name = name;
38 this.enableHhcp = enableHhcp;
39 this.networkId = checkNotNull(networkId);
40 this.tenantId = checkNotNull(tenantId);
41 this.dnsNameservers = dnsNameservers;
42 this.gatewayIp = gatewayIp;
43 this.cidr = checkNotNull(cidr);
44 this.id = checkNotNull(id);
45 }
46
47 /**
48 * Returns OpenstackSubnet builder object.
49 *
50 * @return OpenstackSubnet builder
51 */
52 public static OpenstackSubnet.Builder builder() {
53 return new Builder();
54 }
55
56 public String name() {
57 return name;
58 }
59
60 public boolean enableHhcp() {
61 return enableHhcp;
62 }
63
64 public String networkId() {
65 return networkId;
66 }
67
68 public String tenantId() {
69 return tenantId;
70 }
71
72 public String dnsNameservers() {
73 return dnsNameservers;
74 }
75
76 public String gatewayIp() {
77 return gatewayIp;
78 }
79
80 public String cidr() {
81 return cidr;
82 }
83
84 public String id() {
85 return id;
86 }
87
88 // TODO : Implement the following functions when necessary
89
90 /**
91 * OpenstackSubnet Builder class.
92 *
93 */
94 public static final class Builder {
95 private String name;
96 private boolean enableDhcp;
97 private String networkId;
98 private String tenantId;
99 private String dnsNameservers;
100 private String gatewayIp;
101 private String cidr;
102 private String id;
103
104 Builder() {}
105
106 public Builder setName(String name) {
107 this.name = name;
108
109 return this;
110 }
111
112 public Builder setEnableDhcp(boolean enableDhcp) {
113 this.enableDhcp = enableDhcp;
114
115 return this;
116 }
117
118 public Builder setNetworkId(String networkId) {
119 this.networkId = networkId;
120
121 return this;
122 }
123
124 public Builder setTenantId(String tenantId) {
125 this.tenantId = tenantId;
126
127 return this;
128 }
129
130 public Builder setDnsNameservers(String dnsNameservers) {
131 this.dnsNameservers = dnsNameservers;
132
133 return this;
134 }
135
136 public Builder setGatewayIp(String gatewayIp) {
137 this.gatewayIp = gatewayIp;
138
139 return this;
140 }
141
142 public Builder setCidr(String cidr) {
143 this.cidr = cidr;
144
145 return this;
146 }
147
148 public Builder setId(String id) {
149 this.id = id;
150
151 return this;
152 }
153
154 public OpenstackSubnet build() {
155 return new OpenstackSubnet(name, enableDhcp, networkId, tenantId,
156 dnsNameservers, gatewayIp, cidr, id);
157 }
158 }
159}