blob: 4c3bbe9ab00498fbcef5ec115200ef8e7b20e68f [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 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.tetopology.management.api.node;
17
18import org.onosproject.tetopology.management.api.KeyId;
19import org.onosproject.tetopology.management.api.TeTopologyId;
20
21import com.google.common.base.MoreObjects;
22import com.google.common.base.Objects;
23
24/**
25 * TE Network Topology identifiers.
26 */
27public class TeNetworkTopologyId {
28 private final KeyId networkId;
29 private final TeTopologyId topologyId;
30
31 /**
32 * Creates an instance of TeNetworkTopologyId.
33 *
34 * @param networkId network identifier
35 * @param topologyId topology identifier
36 */
37 public TeNetworkTopologyId(KeyId networkId, TeTopologyId topologyId) {
38 this.networkId = networkId;
39 this.topologyId = topologyId;
40 }
41
42 /**
43 * Creates TeNetworkTopologyId with networkId.
44 *
45 * @param networkId network identifier
46 */
47 public TeNetworkTopologyId(KeyId networkId) {
48 this.networkId = networkId;
49 this.topologyId = null;
50 }
51
52 /**
53 * Creates TeNetworkTopologyId with topologyId.
54 *
55 * @param topologyId topology identifier
56 */
57 public TeNetworkTopologyId(TeTopologyId topologyId) {
58 this.networkId = null;
59 this.topologyId = topologyId;
60 }
61
62 /**
63 * Returns the network identifier.
64 *
65 * @return network id
66 */
67 public KeyId getNetworkId() {
68 return networkId;
69 }
70
71 /**
72 * Returns the topology identifier.
73 *
74 * @return TE topology id
75 */
76 public TeTopologyId getTopologyId() {
77 return topologyId;
78 }
79
80 @Override
81 public int hashCode() {
82 return Objects.hashCode(networkId, topologyId);
83 }
84
85 @Override
86 public boolean equals(Object object) {
87 if (this == object) {
88 return true;
89 }
90 if (object instanceof TeNetworkTopologyId) {
91 TeNetworkTopologyId that = (TeNetworkTopologyId) object;
92 return Objects.equal(this.networkId, that.networkId) &&
93 Objects.equal(this.topologyId, that.topologyId);
94 }
95 return false;
96 }
97
98 @Override
99 public String toString() {
100 return MoreObjects.toStringHelper(this)
101 .add("networkId", networkId)
102 .add("topologyId", topologyId)
103 .toString();
104 }
105
106}