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.IsisLink; |
| 23 | import org.onosproject.isis.controller.topology.IsisLinkTed; |
| 24 | |
| 25 | /** |
| 26 | * Representation of an ISIS Link. |
| 27 | */ |
| 28 | public class DefaultIsisLink implements IsisLink { |
| 29 | |
| 30 | private String remoteSystemId; |
| 31 | private String localSystemId; |
| 32 | private Ip4Address interfaceIp; |
| 33 | private Ip4Address neighborIp; |
| 34 | private IsisLinkTed linkTed; |
| 35 | |
| 36 | @Override |
| 37 | public String remoteSystemId() { |
| 38 | return this.remoteSystemId; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public String localSystemId() { |
| 43 | return this.localSystemId; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public Ip4Address interfaceIp() { |
| 48 | return this.interfaceIp; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Ip4Address neighborIp() { |
| 53 | return this.neighborIp; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public IsisLinkTed linkTed() { |
| 58 | return this.linkTed; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public void setRemoteSystemId(String remoteSystemId) { |
| 63 | this.remoteSystemId = remoteSystemId; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public void setLocalSystemId(String localSystemId) { |
| 68 | this.localSystemId = localSystemId; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public void setInterfaceIp(Ip4Address interfaceIp) { |
| 73 | this.interfaceIp = interfaceIp; |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public void setNeighborIp(Ip4Address neighborIp) { |
| 78 | this.neighborIp = neighborIp; |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public void setLinkTed(IsisLinkTed linkTed) { |
| 83 | this.linkTed = linkTed; |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public String toString() { |
| 88 | return MoreObjects.toStringHelper(getClass()) |
| 89 | .omitNullValues() |
| 90 | .add("remoteSystemId", remoteSystemId) |
| 91 | .add("localSystemId", localSystemId) |
| 92 | .add("interfaceIp", interfaceIp) |
| 93 | .add("neighborIp", neighborIp) |
| 94 | .add("linkTed", linkTed) |
| 95 | .toString(); |
| 96 | } |
| 97 | |
| 98 | @Override |
| 99 | public boolean equals(Object o) { |
| 100 | if (this == o) { |
| 101 | return true; |
| 102 | } |
| 103 | if (o == null || getClass() != o.getClass()) { |
| 104 | return false; |
| 105 | } |
| 106 | DefaultIsisLink that = (DefaultIsisLink) o; |
| 107 | return Objects.equal(remoteSystemId, that.remoteSystemId) && |
| 108 | Objects.equal(localSystemId, that.localSystemId) && |
| 109 | Objects.equal(interfaceIp, that.interfaceIp) && |
| 110 | Objects.equal(neighborIp, that.neighborIp) && |
| 111 | Objects.equal(linkTed, that.linkTed); |
| 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public int hashCode() { |
| 116 | return Objects.hashCode(remoteSystemId, localSystemId, interfaceIp, neighborIp, linkTed); |
| 117 | } |
| 118 | } |