blob: bb80febb9a0de786cb7f941d8be5e74c135c1bb5 [file] [log] [blame]
xuzhang585f9052015-07-22 11:20:13 +08001/*
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.app.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 id using the networkid.
35 *
36 * @param networkid tenantnetwork String
37 * @return NetworkId
38 */
39 public static TenantNetworkId networkId(String networkid) {
40 checkNotNull(networkid, "Networkid cannot be null");
41 return new TenantNetworkId(networkid);
42 }
43
44 /**
45 *
46 * @return tenantNetworkid
47 */
48 public String networkid() {
49 return networkid;
50 }
51
52 @Override
53 public int hashCode() {
54 return Objects.hash(networkid);
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (this == obj) {
60 return true;
61 }
62 if (obj instanceof TenantNetworkId) {
63 final TenantNetworkId that = (TenantNetworkId) obj;
64 return this.getClass() == that.getClass()
65 && Objects.equals(this.networkid, that.networkid);
66 }
67 return false;
68 }
69
70 @Override
71 public String toString() {
72 return networkid;
73 }
74
75}