blob: 3701be73d69bdb97f2763cfe31628daa5468d269 [file] [log] [blame]
Thomas Vachuska7b438af2015-07-07 09:52:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska7b438af2015-07-07 09:52:07 -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.incubator.net.virtual;
17
18import com.google.common.annotations.Beta;
Jian Lib6d998e2016-02-29 11:41:18 -080019import org.onlab.util.Identifier;
Thomas Vachuska7b438af2015-07-07 09:52:07 -070020
21import static com.google.common.base.Preconditions.checkArgument;
22
23/**
24 * Representation of network tenant.
25 */
26@Beta
Jian Lib6d998e2016-02-29 11:41:18 -080027public final class TenantId extends Identifier<String> {
Thomas Vachuska7b438af2015-07-07 09:52:07 -070028
29 /**
30 * Represents no tenant, or an unspecified tenant.
31 */
32 public static final TenantId NONE = new TenantId();
33
Thomas Vachuska7b438af2015-07-07 09:52:07 -070034 // Public construction is prohibited
35 private TenantId(String id) {
Jian Lib6d998e2016-02-29 11:41:18 -080036 super(id);
Thomas Vachuska7b438af2015-07-07 09:52:07 -070037 checkArgument(id != null && id.length() > 0, "Tenant ID cannot be null or empty");
Thomas Vachuska7b438af2015-07-07 09:52:07 -070038 }
39
Thomas Vachuska7b438af2015-07-07 09:52:07 -070040 // Default constructor for serialization
41 protected TenantId() {
Jian Lib6d998e2016-02-29 11:41:18 -080042 super("");
Thomas Vachuska7b438af2015-07-07 09:52:07 -070043 }
44
45 /**
46 * Creates a tenant id using the supplied backing id.
47 *
48 * @param id network id
49 * @return network identifier
50 */
51 public static TenantId tenantId(String id) {
52 return new TenantId(id);
53 }
Thomas Vachuska7b438af2015-07-07 09:52:07 -070054}