blob: 8680d28f8c5dbbf074bf5391c52f347c2fb1f51c [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;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21/**
22 * Immutable representation of a tenantNetwork identity.
23 */
24public final class TenantNetworkId {
25
26 private final String networkId;
27
28 // Public construction is prohibited
29 private TenantNetworkId(String networkId) {
30 this.networkId = networkId;
31 }
32
33 /**
34 * Creates a TenantNetwork identifier.
35 *
36 * @param networkId tenantNetwork identify string
37 * @return the attached tenantNetwork identifier
38 */
39 public static TenantNetworkId networkId(String networkId) {
40 checkNotNull(networkId, "Networkid cannot be null");
41 return new TenantNetworkId(networkId);
42 }
43
44 /**
45 * Returns tenantNetwork identifier.
46 *
47 * @return the tenantNetwork identifier
48 */
49 public String networkId() {
50 return networkId;
51 }
52
53 @Override
54 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070055 return networkId.hashCode();
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -070056 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj instanceof TenantNetworkId) {
64 final TenantNetworkId that = (TenantNetworkId) obj;
65 return this.getClass() == that.getClass()
66 && Objects.equals(this.networkId, that.networkId);
67 }
68 return false;
69 }
70
71 @Override
72 public String toString() {
73 return networkId;
74 }
75
76}