blob: 2cba240cb4ceb45d1d515d9bca66931aa18dd591 [file] [log] [blame]
Priyanka B413fbe82016-05-26 11:44:45 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Priyanka B413fbe82016-05-26 11:44:45 +05303 *
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 */
harikrushna-Huawei6ecfc772017-04-10 18:22:00 +053016package org.onosproject.pcep.server;
Priyanka B413fbe82016-05-26 11:44:45 +053017
18import java.util.Objects;
19
20import com.google.common.base.MoreObjects;
21
22/**
23 * Representation of LSP info, it will be unique for each LSP.
24 */
25public class LspKey {
26 private int plspId;
27 private short localLspId;
28
29 /**
30 * Creates new instance of LspInfo.
31 *
32 * @param plspId LSP id assigned per tunnel per session
33 * @param localLspId LSP id assigned per tunnel
34 */
35 public LspKey(int plspId, short localLspId) {
36 this.plspId = plspId;
37 this.localLspId = localLspId;
38 }
39
40 /**
41 * Obtains PLSP id.
42 *
43 * @return LSP id assigned per tunnel per session
44 */
45 public int plspId() {
46 return plspId;
47 }
48
49 /**
50 * Obtains local LSP id.
51 *
52 * @return LSP id assigned per tunnel
53 */
54 public short localLspId() {
55 return localLspId;
56 }
57
58 @Override
59 public int hashCode() {
60 return Objects.hash(plspId, localLspId);
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj) {
66 return true;
67 }
68
69 if (obj instanceof LspKey) {
70 LspKey other = (LspKey) obj;
71 return Objects.equals(plspId, other.plspId)
72 && Objects.equals(localLspId, other.localLspId);
73 }
74
75 return false;
76 }
77
78 @Override
79 public String toString() {
80 return MoreObjects.toStringHelper(getClass())
81 .add("plspId", plspId)
82 .add("localLspId", localLspId)
83 .toString();
84 }
85}