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