blob: cfab616ce926efb57f1e5ca4a6d9b5becd6b133b [file] [log] [blame]
Henry Yu4b4a7eb2016-11-09 20:07:53 -05001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016 Open Networking Foundation
Henry Yu4b4a7eb2016-11-09 20:07:53 -05003 *
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.ToStringHelper;
19import com.google.common.base.Objects;
20
21/**
22 * TE topology key in long integer format.
23 */
24public class TeTopologyKey extends ProviderClientId {
25 private final long topologyId;
26
27 /**
28 * Creates an instance of TE topology identifier.
29 *
30 * @param providerId provider identifier
31 * @param clientId client identifier
32 * @param topologyId topology identifier
33 */
34 public TeTopologyKey(long providerId, long clientId, long topologyId) {
35 super(providerId, clientId);
36 this.topologyId = topologyId;
37 }
38
39 /**
40 * Returns the topology identifier.
41 *
42 * @return topology identifier
43 */
44 public long topologyId() {
45 return topologyId;
46 }
47
48 @Override
49 public int hashCode() {
50 return Objects.hashCode(super.hashCode(), topologyId);
51 }
52
53 @Override
54 public boolean equals(Object object) {
55 if (this == object) {
56 return true;
57 }
58 if (object instanceof TeTopologyKey) {
59 if (!super.equals(object)) {
60 return false;
61 }
62 TeTopologyKey that = (TeTopologyKey) object;
63 return Objects.equal(topologyId, that.topologyId);
64 }
65 return false;
66 }
67
68 /**
69 * Returns ToStringHelper with additional topologyId.
70 *
71 * @return toStringHelper
72 */
73 protected ToStringHelper toTopologyKeyStringHelper() {
74 return toStringHelper().add("topologyId", topologyId);
75 }
76
77 @Override
78 public String toString() {
79 return toTopologyKeyStringHelper().toString();
80 }
81}