blob: 18b24e10f0634c740ee24c3d6d85411d014322b9 [file] [log] [blame]
Ray Milkey140e4782015-04-24 11:25:13 -07001/*
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.xosintegration;
17
Ray Milkey140e4782015-04-24 11:25:13 -070018import com.google.common.base.MoreObjects;
19
20public final class VoltTenant {
21
22 private final String humanReadableName;
23 private final long id;
24 private final long providerService;
25 private final String serviceSpecificId;
26 private final String vlanId;
27
Ray Milkeydea98172015-05-18 10:39:39 -070028 /**
29 * Constructs a vOLT tenant object.
30 *
31 * @param humanReadableName name string
32 * @param id identifier for the tenant
33 * @param providerService provider service ID
34 * @param serviceSpecificId id for the user
35 * @param vlanId vlan id for the user
36 */
Ray Milkey140e4782015-04-24 11:25:13 -070037 private VoltTenant(String humanReadableName, long id, long providerService,
38 String serviceSpecificId, String vlanId) {
39 this.humanReadableName = humanReadableName;
40 this.id = id;
41 this.providerService = providerService;
42 this.serviceSpecificId = serviceSpecificId;
43 this.vlanId = vlanId;
44 }
45
Ray Milkeydea98172015-05-18 10:39:39 -070046 /**
47 * Fetches a builder to make a tenant.
48 *
49 * @return tenant builder
50 */
Ray Milkey140e4782015-04-24 11:25:13 -070051 public static Builder builder() {
52 return new Builder();
53 }
54
Ray Milkeydea98172015-05-18 10:39:39 -070055 /**
56 * Fetches the name of the tenant.
57 *
58 * @return human readable name
59 */
Ray Milkey140e4782015-04-24 11:25:13 -070060 public String humanReadableName() {
61 return humanReadableName;
62 }
63
Ray Milkeydea98172015-05-18 10:39:39 -070064 /**
65 * Fetches the ID of the tenant object.
66 *
67 * @return ID of tenant object.
68 */
Ray Milkey140e4782015-04-24 11:25:13 -070069 public long id() {
70 return id;
71 }
72
Ray Milkeydea98172015-05-18 10:39:39 -070073 /**
74 * Fetches the identifier for the provider service.
75 *
76 * @return provider service ID
77 */
Ray Milkey140e4782015-04-24 11:25:13 -070078 public long providerService() {
79 return providerService;
80 }
81
Ray Milkeydea98172015-05-18 10:39:39 -070082 /**
83 * Fetches the server specific ID (user id).
84 *
85 * @return server specific ID
86 */
Ray Milkey140e4782015-04-24 11:25:13 -070087 public String serviceSpecificId() {
88 return serviceSpecificId;
89 }
90
Ray Milkeydea98172015-05-18 10:39:39 -070091 /**
92 * Fetches the vlan id for this tenant.
93 *
94 * @return VLAN ID
95 */
Ray Milkey140e4782015-04-24 11:25:13 -070096 public String vlanId() {
97 return vlanId;
98 }
99
Ray Milkeydea98172015-05-18 10:39:39 -0700100 /**
101 * Builder class to allow callers to assemble tenants.
102 */
103
Ray Milkey140e4782015-04-24 11:25:13 -0700104 public static final class Builder {
105 private String humanReadableName = "unknown";
106 private long id = 0;
Ray Milkeydea98172015-05-18 10:39:39 -0700107 private long providerService = -1;
Ray Milkey140e4782015-04-24 11:25:13 -0700108 private String serviceSpecificId = "unknown";
109 private String vlanId = "unknown";
110
Ray Milkeydea98172015-05-18 10:39:39 -0700111 /**
112 * Sets the name string for the tenant.
113 *
114 * @param humanReadableName name
115 * @return self
116 */
Ray Milkey140e4782015-04-24 11:25:13 -0700117 public Builder withHumanReadableName(String humanReadableName) {
118 this.humanReadableName = humanReadableName;
119 return this;
120 }
121
Ray Milkeydea98172015-05-18 10:39:39 -0700122 /**
123 * Sets the identifier for the tenant.
124 *
125 * @param id identifier for the tenant
126 * @return self
127 */
Ray Milkey140e4782015-04-24 11:25:13 -0700128 public Builder withId(long id) {
129 this.id = id;
130 return this;
131 }
132
Ray Milkeydea98172015-05-18 10:39:39 -0700133 /**
134 * Sets the server specific id (user id) for the tenant.
135 *
136 * @param serviceSpecificId server specific (user) id
137 * @return self
138 */
Ray Milkey140e4782015-04-24 11:25:13 -0700139 public Builder withServiceSpecificId(String serviceSpecificId) {
140 this.serviceSpecificId = serviceSpecificId;
141 return this;
142 }
143
Ray Milkeydea98172015-05-18 10:39:39 -0700144 /**
145 * Sets the VLAN ID for the tenant.
146 *
147 * @param vlanId VLAN ID
148 * @return self
149 */
Ray Milkey140e4782015-04-24 11:25:13 -0700150 public Builder withVlanId(String vlanId) {
151 this.vlanId = vlanId;
152 return this;
153 }
154
Ray Milkeydea98172015-05-18 10:39:39 -0700155 /**
156 * Sets the provider service ID.
157 *
158 * @param providerService provider service ID
159 * @return self
160 */
161 public Builder withProviderService(long providerService) {
162 this.providerService = providerService;
163 return this;
164 }
165
166 /**
167 * Constructs a VoltTenant from the assembled data.
168 *
169 * @return constructed tenant object
170 */
Ray Milkey140e4782015-04-24 11:25:13 -0700171 public VoltTenant build() {
172 return new VoltTenant(humanReadableName, id, providerService,
173 serviceSpecificId, vlanId);
174 }
175 }
176
177 @Override
178 public String toString() {
179 return MoreObjects.toStringHelper(getClass())
180 .add("humanReadableName", humanReadableName())
181 .add("id", id())
182 .add("providerService", providerService())
183 .add("serviceSpecificId", serviceSpecificId())
184 .add("vlanId", vlanId())
185 .toString();
186 }
187
188}