blob: 86d96acbdac412e5651de761e7c36b18d393b4c7 [file] [log] [blame]
Satish Kf6d87cb2015-11-30 19:59:22 +05301/*
2 * Copyright 2015 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.iptopology.api;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Objects;
21
22import org.onlab.packet.Ip4Address;
23
24/**
25 * Represents Pseudonode information of OSFP device.
26 */
27public class OspfPseudonode implements RouteIdentifier {
28 private final RouterId designatedRouter;
29 private final Ip4Address drInterface;
30 private final ProtocolType type;
31
32 /**
33 * Constructor to initialize the values.
34 *
35 * @param designatedRouter Router Id of designated router
36 * @param drInterface IP address of Designated Router interface
37 * @param type Protocol ID
38 */
39 public OspfPseudonode(RouterId designatedRouter, Ip4Address drInterface, ProtocolType type) {
40 this.designatedRouter = designatedRouter;
41 this.drInterface = drInterface;
42 this.type = type;
43 }
44
45 /**
46 * Obtains designated Router Id.
47 *
48 * @return designated Router Id
49 */
50 public RouterId designatedRouter() {
51 return designatedRouter;
52 }
53
54 /**
55 * Obtains IP address of Designated Router interface.
56 *
57 * @return IP address of Designated Router interface
58 */
59 public Ip4Address drInterface() {
60 return drInterface;
61 }
62
63 @Override
64 public ProtocolType type() {
65 return type;
66 }
67
68 @Override
69 public int hashCode() {
70 return Objects.hash(designatedRouter, drInterface, type);
71 }
72
73 @Override
74 public boolean equals(Object obj) {
75 if (this == obj) {
76 return true;
77 }
78
79 if (obj instanceof OspfPseudonode) {
80 OspfPseudonode other = (OspfPseudonode) obj;
81 return Objects.equals(designatedRouter, other.designatedRouter)
82 && Objects.equals(drInterface, other.drInterface)
83 && Objects.equals(type, other.type);
84 }
85 return false;
86 }
87
88 @Override
89 public String toString() {
90 return toStringHelper(this)
91 .add("designatedRouter", designatedRouter)
92 .add("drInterface", drInterface)
93 .add("type", type)
94 .toString();
95 }
96}