Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.xosintegration; |
| 17 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 19 | import org.onosproject.net.ConnectPoint; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 20 | |
| 21 | public 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 Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 28 | private final ConnectPoint port; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 29 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 30 | /** |
| 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 Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 39 | private VoltTenant(String humanReadableName, long id, long providerService, |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 40 | String serviceSpecificId, String vlanId, ConnectPoint port) { |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 41 | this.humanReadableName = humanReadableName; |
| 42 | this.id = id; |
| 43 | this.providerService = providerService; |
| 44 | this.serviceSpecificId = serviceSpecificId; |
| 45 | this.vlanId = vlanId; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 46 | this.port = port; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 49 | /** |
| 50 | * Fetches a builder to make a tenant. |
| 51 | * |
| 52 | * @return tenant builder |
| 53 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 54 | public static Builder builder() { |
| 55 | return new Builder(); |
| 56 | } |
| 57 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 58 | /** |
| 59 | * Fetches the name of the tenant. |
| 60 | * |
| 61 | * @return human readable name |
| 62 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 63 | public String humanReadableName() { |
| 64 | return humanReadableName; |
| 65 | } |
| 66 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 67 | /** |
| 68 | * Fetches the ID of the tenant object. |
| 69 | * |
| 70 | * @return ID of tenant object. |
| 71 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 72 | public long id() { |
| 73 | return id; |
| 74 | } |
| 75 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 76 | /** |
| 77 | * Fetches the identifier for the provider service. |
| 78 | * |
| 79 | * @return provider service ID |
| 80 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 81 | public long providerService() { |
| 82 | return providerService; |
| 83 | } |
| 84 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 85 | /** |
| 86 | * Fetches the server specific ID (user id). |
| 87 | * |
| 88 | * @return server specific ID |
| 89 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 90 | public String serviceSpecificId() { |
| 91 | return serviceSpecificId; |
| 92 | } |
| 93 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Fetches the vlan id for this tenant. |
| 96 | * |
| 97 | * @return VLAN ID |
| 98 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 99 | public String vlanId() { |
| 100 | return vlanId; |
| 101 | } |
| 102 | |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 103 | public ConnectPoint port() { |
| 104 | return port; |
| 105 | } |
| 106 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 107 | /** |
| 108 | * Builder class to allow callers to assemble tenants. |
| 109 | */ |
| 110 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 111 | public static final class Builder { |
| 112 | private String humanReadableName = "unknown"; |
| 113 | private long id = 0; |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 114 | private long providerService = -1; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 115 | private String serviceSpecificId = "unknown"; |
| 116 | private String vlanId = "unknown"; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 117 | private ConnectPoint port; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 118 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 119 | /** |
| 120 | * Sets the name string for the tenant. |
| 121 | * |
| 122 | * @param humanReadableName name |
| 123 | * @return self |
| 124 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 125 | public Builder withHumanReadableName(String humanReadableName) { |
| 126 | this.humanReadableName = humanReadableName; |
| 127 | return this; |
| 128 | } |
| 129 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 130 | /** |
| 131 | * Sets the identifier for the tenant. |
| 132 | * |
| 133 | * @param id identifier for the tenant |
| 134 | * @return self |
| 135 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 136 | public Builder withId(long id) { |
| 137 | this.id = id; |
| 138 | return this; |
| 139 | } |
| 140 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 141 | /** |
| 142 | * Sets the server specific id (user id) for the tenant. |
| 143 | * |
| 144 | * @param serviceSpecificId server specific (user) id |
| 145 | * @return self |
| 146 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 147 | public Builder withServiceSpecificId(String serviceSpecificId) { |
| 148 | this.serviceSpecificId = serviceSpecificId; |
| 149 | return this; |
| 150 | } |
| 151 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 152 | /** |
| 153 | * Sets the VLAN ID for the tenant. |
| 154 | * |
| 155 | * @param vlanId VLAN ID |
| 156 | * @return self |
| 157 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 158 | public Builder withVlanId(String vlanId) { |
| 159 | this.vlanId = vlanId; |
| 160 | return this; |
| 161 | } |
| 162 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 163 | /** |
| 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 Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 174 | public Builder withPort(ConnectPoint port) { |
| 175 | this.port = port; |
| 176 | return this; |
| 177 | } |
| 178 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 179 | /** |
| 180 | * Constructs a VoltTenant from the assembled data. |
| 181 | * |
| 182 | * @return constructed tenant object |
| 183 | */ |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 184 | public VoltTenant build() { |
| 185 | return new VoltTenant(humanReadableName, id, providerService, |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 186 | serviceSpecificId, vlanId, port); |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 187 | } |
| 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 Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 198 | .add("port", port()) |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 199 | .toString(); |
| 200 | } |
| 201 | |
| 202 | } |