blob: ca221c7abd70c3b675f57ae9c2697c67c07df366 [file] [log] [blame]
lishuai8798bbe2016-05-05 16:02:03 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
lishuai8798bbe2016-05-05 16:02:03 +08003 *
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 static com.google.common.base.MoreObjects.toStringHelper;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21import java.util.Objects;
22
23public final class TenantRouter {
24 private final TenantId tenantId;
25 private final RouterId routerId;
26
27 /**
28 * Construct a TenantRouter object.
29 *
30 * @param tenantId the tenant identifier
31 * @param routerId router identifier
32 */
33 private TenantRouter(TenantId tenantId, RouterId routerId) {
34 this.tenantId = checkNotNull(tenantId, "tenantId cannot be null");
35 this.routerId = checkNotNull(routerId, "routerId cannot be null");
36 }
37
38 /**
39 * Create a TenantRouter object.
40 *
41 * @param tenantId the tenant identifier
42 * @param routerId router identifier
43 * @return TenantRouter
44 */
45 public static TenantRouter tenantRouter(TenantId tenantId, RouterId routerId) {
46 return new TenantRouter(tenantId, routerId);
47 }
48
49 public TenantId tenantId() {
50 return tenantId;
51 }
52
53 public RouterId routerId() {
54 return routerId;
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(tenantId, routerId);
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (this == obj) {
65 return true;
66 }
67 if (obj instanceof TenantRouter) {
68 final TenantRouter that = (TenantRouter) obj;
69 return this.getClass() == that.getClass()
70 && Objects.equals(this.tenantId, that.tenantId)
71 && Objects.equals(this.routerId, that.routerId);
72 }
73 return false;
74 }
75
76 @Override
77 public String toString() {
78 return toStringHelper(this)
79 .add("tenantId", tenantId)
80 .add("routerId", routerId)
81 .toString();
82 }
83}