blob: 90bc131d7b9fd5295cef8a85bb69efb11eb00775 [file] [log] [blame]
sunish vk7bdf4d42016-06-24 12:29:43 +05301/*
Brian O'Connor0a4e6742016-09-15 23:03:10 -07002 * Copyright 2016-present Open Networking Laboratory
sunish vk7bdf4d42016-06-24 12:29:43 +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 */
16
17package org.onosproject.isis.controller.impl.topology;
18
19import com.google.common.base.MoreObjects;
20import com.google.common.base.Objects;
21import org.onlab.packet.Ip4Address;
22import org.onosproject.isis.controller.topology.IsisRouter;
23
24/**
25 * Representation of an ISIS Router.
26 */
27public class DefaultIsisRouter implements IsisRouter {
28
29 private String systemId;
30 private Ip4Address neighborRouterId;
31 private Ip4Address interfaceId;
32 private boolean isDis;
33
34 /**
35 * Gets the system ID.
36 *
37 * @return systemId system ID
38 */
39 public String systemId() {
40 return systemId;
41 }
42
43 /**
44 * Sets IP address of the Router.
45 */
46 public void setSystemId(String systemId) {
47 this.systemId = systemId;
48 }
49
50 /**
51 * Gets IP address of the interface.
52 *
53 * @return IP address of the interface
54 */
55 public Ip4Address interfaceId() {
56 return interfaceId;
57 }
58
59 /**
60 * Gets IP address of the interface.
61 *
62 * @param interfaceId IP address of the interface
63 */
64 public void setInterfaceId(Ip4Address interfaceId) {
65 this.interfaceId = interfaceId;
66 }
67
68 /**
69 * Gets neighbor's Router id.
70 *
71 * @return neighbor's Router id
72 */
73 public Ip4Address neighborRouterId() {
74 return neighborRouterId;
75 }
76
77 /**
78 * Sets neighbor's Router id.
79 *
80 * @param advertisingRouterId neighbor's Router id
81 */
82 public void setNeighborRouterId(Ip4Address advertisingRouterId) {
83 this.neighborRouterId = advertisingRouterId;
84 }
85
86 /**
87 * Gets if DR or not.
88 *
89 * @return true if DR else false
90 */
91 public boolean isDis() {
92 return isDis;
93 }
94
95 /**
96 * Sets dis or not.
97 *
98 * @param dis true if DIS else false
99 */
100 public void setDis(boolean dis) {
101 isDis = dis;
102 }
103
104 @Override
105 public String toString() {
106 return MoreObjects.toStringHelper(getClass())
107 .omitNullValues()
108 .add("systemId", systemId)
109 .add("neighborRouterId", neighborRouterId)
110 .add("interfaceId", interfaceId)
111 .toString();
112 }
113
114 @Override
115 public boolean equals(Object o) {
116 if (this == o) {
117 return true;
118 }
119 if (o == null || getClass() != o.getClass()) {
120 return false;
121 }
122 DefaultIsisRouter that = (DefaultIsisRouter) o;
123 return Objects.equal(systemId, that.systemId) &&
124 Objects.equal(neighborRouterId, that.neighborRouterId) &&
125 Objects.equal(interfaceId, that.interfaceId);
126 }
127
128 @Override
129 public int hashCode() {
130 return Objects.hashCode(systemId, neighborRouterId, interfaceId);
131 }
132}