Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present 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 | */ |
| 16 | package org.onosproject.pcep.controller; |
| 17 | |
| 18 | import java.util.Objects; |
| 19 | |
| 20 | import com.google.common.base.MoreObjects; |
| 21 | |
| 22 | /** |
| 23 | * Representation of LSP info, it will be unique for each LSP. |
| 24 | */ |
| 25 | public 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 | } |