blob: 03ff6bff30f902ca968678d2f61b6fc66dcb6026 [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
xuzhang41ad7282015-08-07 15:07:34 +080026 private final String networkId;
xuzhang585f9052015-07-22 11:20:13 +080027
28 // Public construction is prohibited
xuzhang41ad7282015-08-07 15:07:34 +080029 private TenantNetworkId(String networkId) {
30 this.networkId = networkId;
xuzhang585f9052015-07-22 11:20:13 +080031 }
32
33 /**
xuzhang41ad7282015-08-07 15:07:34 +080034 * Creates a TenantNetwork identifier.
xuzhang585f9052015-07-22 11:20:13 +080035 *
xuzhang41ad7282015-08-07 15:07:34 +080036 * @param networkId tenantNetwork identify string
37 * @return the attached tenantNetwork identifier
xuzhang585f9052015-07-22 11:20:13 +080038 */
xuzhang41ad7282015-08-07 15:07:34 +080039 public static TenantNetworkId networkId(String networkId) {
40 checkNotNull(networkId, "Networkid cannot be null");
41 return new TenantNetworkId(networkId);
xuzhang585f9052015-07-22 11:20:13 +080042 }
43
44 /**
xuzhang41ad7282015-08-07 15:07:34 +080045 * Returns tenantNetwork identifier.
xuzhang585f9052015-07-22 11:20:13 +080046 *
xuzhang41ad7282015-08-07 15:07:34 +080047 * @return the tenantNetwork identifier
xuzhang585f9052015-07-22 11:20:13 +080048 */
xuzhang41ad7282015-08-07 15:07:34 +080049 public String networkId() {
50 return networkId;
xuzhang585f9052015-07-22 11:20:13 +080051 }
52
53 @Override
54 public int hashCode() {
xuzhang41ad7282015-08-07 15:07:34 +080055 return Objects.hash(networkId);
xuzhang585f9052015-07-22 11:20:13 +080056 }
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()
xuzhang41ad7282015-08-07 15:07:34 +080066 && Objects.equals(this.networkId, that.networkId);
xuzhang585f9052015-07-22 11:20:13 +080067 }
68 return false;
69 }
70
71 @Override
72 public String toString() {
xuzhang41ad7282015-08-07 15:07:34 +080073 return networkId;
xuzhang585f9052015-07-22 11:20:13 +080074 }
75
76}