blob: f70bbe6f111b201e63138d48d2e7f4582a6df806 [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016 Open Networking Foundation
Aihua Guo1ce2dd12016-08-12 23:37:44 -04003 *
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.tetopology.management.api;
17
18import com.google.common.base.MoreObjects;
Henry Yu4b4a7eb2016-11-09 20:07:53 -050019import com.google.common.base.MoreObjects.ToStringHelper;
Aihua Guo1ce2dd12016-08-12 23:37:44 -040020import com.google.common.base.Objects;
21
22/**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050023 * TE topology provider and client identifiers.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040024 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050025public abstract class ProviderClientId {
Aihua Guo1ce2dd12016-08-12 23:37:44 -040026 private final long providerId;
27 private final long clientId;
Aihua Guo1ce2dd12016-08-12 23:37:44 -040028
29 /**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050030 * Creates an instance of TE topology provider client identifier.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040031 *
Henry Yu4b4a7eb2016-11-09 20:07:53 -050032 * @param providerId provider identifier
33 * @param clientId client identifier
Aihua Guo1ce2dd12016-08-12 23:37:44 -040034 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050035 public ProviderClientId(long providerId, long clientId) {
Aihua Guo1ce2dd12016-08-12 23:37:44 -040036 this.providerId = providerId;
37 this.clientId = clientId;
Aihua Guo1ce2dd12016-08-12 23:37:44 -040038 }
39
40 /**
41 * Returns the provider identifier.
42 *
43 * @return provider identifier
44 */
45 public long providerId() {
46 return providerId;
47 }
48
49 /**
50 * Returns the client identifier.
51 *
52 * @return client identifier
53 */
54 public long clientId() {
55 return clientId;
56 }
57
Aihua Guo1ce2dd12016-08-12 23:37:44 -040058 @Override
59 public int hashCode() {
Henry Yu4b4a7eb2016-11-09 20:07:53 -050060 return Objects.hashCode(providerId, clientId);
Aihua Guo1ce2dd12016-08-12 23:37:44 -040061 }
62
63 @Override
64 public boolean equals(Object object) {
65 if (this == object) {
66 return true;
67 }
Henry Yu4b4a7eb2016-11-09 20:07:53 -050068 if (object instanceof ProviderClientId) {
69 ProviderClientId that = (ProviderClientId) object;
70 return Objects.equal(providerId, that.providerId) &&
71 Objects.equal(clientId, that.clientId);
Aihua Guo1ce2dd12016-08-12 23:37:44 -040072 }
73 return false;
74 }
75
Henry Yu4b4a7eb2016-11-09 20:07:53 -050076 /**
77 * Returns ToStringHelper with providerId and clientId.
78 *
79 * @return toStringHelper
80 */
81 protected ToStringHelper toStringHelper() {
Aihua Guo1ce2dd12016-08-12 23:37:44 -040082 return MoreObjects.toStringHelper(this)
83 .add("providerId", providerId)
Henry Yu4b4a7eb2016-11-09 20:07:53 -050084 .add("clientId", clientId);
85 }
86
87 @Override
88 public String toString() {
89 return toStringHelper().toString();
Aihua Guo1ce2dd12016-08-12 23:37:44 -040090 }
91}