blob: 829233b430533186c0eb4c2e1d30c1e6380d22c7 [file] [log] [blame]
tony-liuaff59a72016-10-21 15:41:46 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
tony-liuaff59a72016-10-21 15:41:46 +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 */
16
17package org.onosproject.tetunnel.api.lsp;
18
19import com.google.common.base.Objects;
20import org.onosproject.tetopology.management.api.TeTopologyKey;
21
22/**
23 * Representation of a TE LSP key, which identifies a TE Label-switched path
24 * globally.
25 */
26public class TeLspKey extends TeTopologyKey {
27
28 private final long teLspId;
29
30 /**
31 * Creates an instance of TeLspKey with supplied information.
32 *
33 * @param providerId provider identifier
34 * @param clientId client identifier
35 * @param topologyId topology identifier
36 * @param teLspId TE LSP identifier
37 */
38 public TeLspKey(long providerId, long clientId,
39 long topologyId, long teLspId) {
40 super(providerId, clientId, topologyId);
41 this.teLspId = teLspId;
42 }
43
44 /**
45 * Creates an instance of TeLspKey with specified TeTopologyKey and
46 * supplied TE LSP identifier.
47 *
48 * @param key the key of TE Topology to which this LSP belongs
49 * @param teLspId TE LSP identifier
50 */
51 public TeLspKey(TeTopologyKey key, long teLspId) {
52 super(key.providerId(), key.clientId(), key.topologyId());
53 this.teLspId = teLspId;
54 }
55
56 /**
57 * Returns the TE LSP identifier corresponding to this key.
58 *
59 * @return TE LSP identifier
60 */
61 public long teLspId() {
62 return teLspId;
63 }
64
65 /**
66 * Returns the key of the TE topology to which this LSP belongs.
67 *
68 * @return corresponding TE topology key
69 */
70 public TeTopologyKey teTopologyKey() {
71 return new TeTopologyKey(providerId(), clientId(), topologyId());
72 }
73
74 @Override
75 public int hashCode() {
76 return Objects.hashCode(super.hashCode(), teLspId);
77 }
78
79 @Override
80 public boolean equals(Object object) {
81 if (this == object) {
82 return true;
83 }
84 if (object instanceof TeLspKey) {
85 if (!super.equals(object)) {
86 return false;
87 }
88 TeLspKey that = (TeLspKey) object;
89 return Objects.equal(this.teLspId, that.teLspId);
90 }
91 return false;
92 }
93
94 @Override
95 public String toString() {
96 return toStringHelper()
97 .add("topologyId", topologyId())
98 .add("teLspId", teLspId)
99 .toString();
100 }
101}
102