blob: 05bc04cfa8703c1f1e2c83d024a1a44f38dbc66b [file] [log] [blame]
Ray Milkey140e4782015-04-24 11:25:13 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkey140e4782015-04-24 11:25:13 -07003 *
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.xosintegration;
17
Ray Milkey140e4782015-04-24 11:25:13 -070018import com.google.common.base.MoreObjects;
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070019import org.onosproject.net.ConnectPoint;
Ray Milkey140e4782015-04-24 11:25:13 -070020
21public final class VoltTenant {
22
23 private final String humanReadableName;
24 private final long id;
25 private final long providerService;
26 private final String serviceSpecificId;
27 private final String vlanId;
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070028 private final ConnectPoint port;
Ray Milkey140e4782015-04-24 11:25:13 -070029
Ray Milkeydea98172015-05-18 10:39:39 -070030 /**
31 * Constructs a vOLT tenant object.
32 *
33 * @param humanReadableName name string
34 * @param id identifier for the tenant
35 * @param providerService provider service ID
36 * @param serviceSpecificId id for the user
37 * @param vlanId vlan id for the user
38 */
Ray Milkey140e4782015-04-24 11:25:13 -070039 private VoltTenant(String humanReadableName, long id, long providerService,
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070040 String serviceSpecificId, String vlanId, ConnectPoint port) {
Ray Milkey140e4782015-04-24 11:25:13 -070041 this.humanReadableName = humanReadableName;
42 this.id = id;
43 this.providerService = providerService;
44 this.serviceSpecificId = serviceSpecificId;
45 this.vlanId = vlanId;
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070046 this.port = port;
Ray Milkey140e4782015-04-24 11:25:13 -070047 }
48
Ray Milkeydea98172015-05-18 10:39:39 -070049 /**
50 * Fetches a builder to make a tenant.
51 *
52 * @return tenant builder
53 */
Ray Milkey140e4782015-04-24 11:25:13 -070054 public static Builder builder() {
55 return new Builder();
56 }
57
Ray Milkeydea98172015-05-18 10:39:39 -070058 /**
59 * Fetches the name of the tenant.
60 *
61 * @return human readable name
62 */
Ray Milkey140e4782015-04-24 11:25:13 -070063 public String humanReadableName() {
64 return humanReadableName;
65 }
66
Ray Milkeydea98172015-05-18 10:39:39 -070067 /**
68 * Fetches the ID of the tenant object.
69 *
70 * @return ID of tenant object.
71 */
Ray Milkey140e4782015-04-24 11:25:13 -070072 public long id() {
73 return id;
74 }
75
Ray Milkeydea98172015-05-18 10:39:39 -070076 /**
77 * Fetches the identifier for the provider service.
78 *
79 * @return provider service ID
80 */
Ray Milkey140e4782015-04-24 11:25:13 -070081 public long providerService() {
82 return providerService;
83 }
84
Ray Milkeydea98172015-05-18 10:39:39 -070085 /**
86 * Fetches the server specific ID (user id).
87 *
88 * @return server specific ID
89 */
Ray Milkey140e4782015-04-24 11:25:13 -070090 public String serviceSpecificId() {
91 return serviceSpecificId;
92 }
93
Ray Milkeydea98172015-05-18 10:39:39 -070094 /**
95 * Fetches the vlan id for this tenant.
96 *
97 * @return VLAN ID
98 */
Ray Milkey140e4782015-04-24 11:25:13 -070099 public String vlanId() {
100 return vlanId;
101 }
102
Jonathan Hart5e9a63d2015-05-19 16:21:46 -0700103 public ConnectPoint port() {
104 return port;
105 }
106
Ray Milkeydea98172015-05-18 10:39:39 -0700107 /**
108 * Builder class to allow callers to assemble tenants.
109 */
110
Ray Milkey140e4782015-04-24 11:25:13 -0700111 public static final class Builder {
112 private String humanReadableName = "unknown";
113 private long id = 0;
Ray Milkeydea98172015-05-18 10:39:39 -0700114 private long providerService = -1;
Ray Milkey140e4782015-04-24 11:25:13 -0700115 private String serviceSpecificId = "unknown";
116 private String vlanId = "unknown";
Jonathan Hart5e9a63d2015-05-19 16:21:46 -0700117 private ConnectPoint port;
Ray Milkey140e4782015-04-24 11:25:13 -0700118
Ray Milkeydea98172015-05-18 10:39:39 -0700119 /**
120 * Sets the name string for the tenant.
121 *
122 * @param humanReadableName name
123 * @return self
124 */
Ray Milkey140e4782015-04-24 11:25:13 -0700125 public Builder withHumanReadableName(String humanReadableName) {
126 this.humanReadableName = humanReadableName;
127 return this;
128 }
129
Ray Milkeydea98172015-05-18 10:39:39 -0700130 /**
131 * Sets the identifier for the tenant.
132 *
133 * @param id identifier for the tenant
134 * @return self
135 */
Ray Milkey140e4782015-04-24 11:25:13 -0700136 public Builder withId(long id) {
137 this.id = id;
138 return this;
139 }
140
Ray Milkeydea98172015-05-18 10:39:39 -0700141 /**
142 * Sets the server specific id (user id) for the tenant.
143 *
144 * @param serviceSpecificId server specific (user) id
145 * @return self
146 */
Ray Milkey140e4782015-04-24 11:25:13 -0700147 public Builder withServiceSpecificId(String serviceSpecificId) {
148 this.serviceSpecificId = serviceSpecificId;
149 return this;
150 }
151
Ray Milkeydea98172015-05-18 10:39:39 -0700152 /**
153 * Sets the VLAN ID for the tenant.
154 *
155 * @param vlanId VLAN ID
156 * @return self
157 */
Ray Milkey140e4782015-04-24 11:25:13 -0700158 public Builder withVlanId(String vlanId) {
159 this.vlanId = vlanId;
160 return this;
161 }
162
Ray Milkeydea98172015-05-18 10:39:39 -0700163 /**
164 * Sets the provider service ID.
165 *
166 * @param providerService provider service ID
167 * @return self
168 */
169 public Builder withProviderService(long providerService) {
170 this.providerService = providerService;
171 return this;
172 }
173
Jonathan Hart5e9a63d2015-05-19 16:21:46 -0700174 public Builder withPort(ConnectPoint port) {
175 this.port = port;
176 return this;
177 }
178
Ray Milkeydea98172015-05-18 10:39:39 -0700179 /**
180 * Constructs a VoltTenant from the assembled data.
181 *
182 * @return constructed tenant object
183 */
Ray Milkey140e4782015-04-24 11:25:13 -0700184 public VoltTenant build() {
185 return new VoltTenant(humanReadableName, id, providerService,
Jonathan Hart5e9a63d2015-05-19 16:21:46 -0700186 serviceSpecificId, vlanId, port);
Ray Milkey140e4782015-04-24 11:25:13 -0700187 }
188 }
189
190 @Override
191 public String toString() {
192 return MoreObjects.toStringHelper(getClass())
193 .add("humanReadableName", humanReadableName())
194 .add("id", id())
195 .add("providerService", providerService())
196 .add("serviceSpecificId", serviceSpecificId())
197 .add("vlanId", vlanId())
Jonathan Hart5e9a63d2015-05-19 16:21:46 -0700198 .add("port", port())
Ray Milkey140e4782015-04-24 11:25:13 -0700199 .toString();
200 }
201
202}