blob: 0e7c94173987cd7767cc901c021ba2594f03f3bc [file] [log] [blame]
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -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.vtnrsc;
17
18import java.util.Objects;
19
20import static com.google.common.base.Preconditions.checkNotNull;
21
22/**
23 * Immutable representation of a tenant identifier.
24 */
25public final class TenantId {
26
27 private final String tenantId;
28
29 // Public construction is prohibited
30 private TenantId(String tenantId) {
31 this.tenantId = tenantId;
32 }
33
34 /**
35 * Creates a network id using the tenantid.
36 *
37 * @param tenantid network String
38 * @return TenantId
39 */
40 public static TenantId tenantId(String tenantid) {
41 checkNotNull(tenantid, "Tenantid can not be null");
42 return new TenantId(tenantid);
43 }
44
45 /**
46 * Returns the tenant identifier.
47 *
48 * @return the tenant identifier
49 */
50 public String tenantId() {
51 return tenantId;
52 }
53
54 @Override
55 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070056 return tenantId.hashCode();
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -070057 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj) {
62 return true;
63 }
64 if (obj instanceof TenantId) {
65 final TenantId that = (TenantId) obj;
66 return this.getClass() == that.getClass()
67 && Objects.equals(this.tenantId, that.tenantId);
68 }
69 return false;
70 }
71
72 @Override
73 public String toString() {
74 return tenantId;
75 }
76
77}