Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 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.vtnrsc; |
| 17 | |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 18 | import org.onlab.util.Identifier; |
Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 19 | |
| 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | |
| 22 | /** |
| 23 | * Immutable representation of a tenant identifier. |
| 24 | */ |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 25 | public final class TenantId extends Identifier<String> { |
Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 26 | // Public construction is prohibited |
| 27 | private TenantId(String tenantId) { |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 28 | super(tenantId); |
Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Creates a network id using the tenantid. |
| 33 | * |
| 34 | * @param tenantid network String |
| 35 | * @return TenantId |
| 36 | */ |
| 37 | public static TenantId tenantId(String tenantid) { |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 38 | checkNotNull(tenantid, "Tenant id can not be null"); |
Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 39 | return new TenantId(tenantid); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns the tenant identifier. |
| 44 | * |
| 45 | * @return the tenant identifier |
| 46 | */ |
| 47 | public String tenantId() { |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 48 | return identifier; |
Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 49 | } |
Sho SHIMIZU | b2b2d98 | 2015-09-11 15:35:06 -0700 | [diff] [blame] | 50 | } |