blob: de53d114ac7eed2f8979e8f05c5b148bd278b75b [file] [log] [blame]
Satish Kf6d87cb2015-11-30 19:59:22 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Satish Kf6d87cb2015-11-30 19:59:22 +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 */
16package org.onosproject.iptopology.api;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Objects;
21
22/**
23 * Represents the Pseudonode information of device in ISIS domain.
24 */
25public class IsIsPseudonode implements RouteIdentifier {
26 private final IsoNodeId isoNodeId;
27 private final byte psnIdentifier;
28 private final ProtocolType type;
29
30 /**
31 * Constructor to initialize the values.
32 *
33 * @param isoNodeId ISO system-ID
34 * @param psnIdentifier Pseudonode identifier
35 * @param type Protocol ID
36 */
37 public IsIsPseudonode(IsoNodeId isoNodeId, byte psnIdentifier, ProtocolType type) {
38 this.isoNodeId = isoNodeId;
39 this.psnIdentifier = psnIdentifier;
40 this.type = type;
41 }
42
43 /**
44 * Obtains iso system id of Pseudonode of device in ISIS domain.
45 *
46 * @return ISO system Id
47 */
48 public IsoNodeId isoNodeId() {
49 return isoNodeId;
50 }
51
52 /**
53 * Obtains Pseudonode identifier.
54 *
55 * @return Pseudonode identifier
56 */
57 public byte psnIdentifier() {
58 return psnIdentifier;
59 }
60
61 @Override
62 public ProtocolType type() {
63 return type;
64 }
65
66 @Override
67 public int hashCode() {
68 return Objects.hash(isoNodeId, psnIdentifier, type);
69 }
70
71 @Override
72 public boolean equals(Object obj) {
73 if (this == obj) {
74 return true;
75 }
76
77 if (obj instanceof IsIsPseudonode) {
78 IsIsPseudonode other = (IsIsPseudonode) obj;
79 return Objects.equals(isoNodeId, other.isoNodeId) && Objects.equals(psnIdentifier, other.psnIdentifier)
80 && Objects.equals(type, other.type);
81 }
82 return false;
83 }
84
85 @Override
86 public String toString() {
87 return toStringHelper(this)
88 .add("isoNodeId", isoNodeId)
89 .add("psnIdentifier", psnIdentifier)
90 .add("type", type)
91 .toString();
92 }
93}