sunish vk | 7bdf4d4 | 2016-06-24 12:29:43 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 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 | */ |
| 16 | package org.onosproject.isis.controller.impl.topology; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | import com.google.common.base.Objects; |
| 20 | import org.onlab.packet.Ip4Address; |
| 21 | import org.onlab.util.Bandwidth; |
| 22 | import org.onosproject.isis.controller.topology.IsisLinkTed; |
| 23 | |
| 24 | import java.util.ArrayList; |
| 25 | import java.util.List; |
| 26 | |
| 27 | /** |
| 28 | * Representation of an ISIS device information. |
| 29 | */ |
| 30 | public class DefaultIsisLinkTed implements IsisLinkTed { |
| 31 | private int administrativeGroup; |
| 32 | private Ip4Address ipv4InterfaceAddress; |
| 33 | private Ip4Address ipv4NeighborAddress; |
| 34 | private Bandwidth maximumLinkBandwidth; |
| 35 | private Bandwidth maximumReservableLinkBandwidth; |
| 36 | private List<Bandwidth> unreservedBandwidth = new ArrayList<>(); |
| 37 | private long teDefaultMetric; |
| 38 | |
| 39 | @Override |
| 40 | public int administrativeGroup() { |
| 41 | return administrativeGroup; |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public void setAdministrativeGroup(int administrativeGroup) { |
| 46 | this.administrativeGroup = administrativeGroup; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public Ip4Address ipv4InterfaceAddress() { |
| 51 | return ipv4InterfaceAddress; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public void setIpv4InterfaceAddress(Ip4Address interfaceAddress) { |
| 56 | this.ipv4InterfaceAddress = interfaceAddress; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public Ip4Address ipv4NeighborAddress() { |
| 61 | return ipv4NeighborAddress; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public void setIpv4NeighborAddress(Ip4Address neighborAddress) { |
| 66 | this.ipv4NeighborAddress = neighborAddress; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public Bandwidth maximumLinkBandwidth() { |
| 71 | return maximumLinkBandwidth; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public void setMaximumLinkBandwidth(Bandwidth bandwidth) { |
| 76 | this.maximumLinkBandwidth = bandwidth; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public Bandwidth maximumReservableLinkBandwidth() { |
| 81 | return maximumReservableLinkBandwidth; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public void setMaximumReservableLinkBandwidth(Bandwidth bandwidth) { |
| 86 | this.maximumReservableLinkBandwidth = bandwidth; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public List<Bandwidth> unreservedBandwidth() { |
| 91 | return this.unreservedBandwidth; |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public void setUnreservedBandwidth(List<Bandwidth> bandwidth) { |
| 96 | this.unreservedBandwidth.addAll(bandwidth); |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public long teDefaultMetric() { |
| 101 | return teDefaultMetric; |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public void setTeDefaultMetric(long teMetric) { |
| 106 | this.teDefaultMetric = teMetric; |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public String toString() { |
| 111 | return MoreObjects.toStringHelper(getClass()) |
| 112 | .omitNullValues() |
| 113 | .add("administrativeGroup", administrativeGroup) |
| 114 | .add("ipv4InterfaceAddress", ipv4InterfaceAddress) |
| 115 | .add("ipv4NeighborAddress", ipv4NeighborAddress) |
| 116 | .add("maximumLinkBandwidth", maximumLinkBandwidth) |
| 117 | .add("maximumReservableLinkBandwidth", maximumReservableLinkBandwidth) |
| 118 | .add("teDefaultMetric", teDefaultMetric) |
| 119 | .toString(); |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public boolean equals(Object o) { |
| 124 | if (this == o) { |
| 125 | return true; |
| 126 | } |
| 127 | if (o == null || getClass() != o.getClass()) { |
| 128 | return false; |
| 129 | } |
| 130 | DefaultIsisLinkTed that = (DefaultIsisLinkTed) o; |
| 131 | return Objects.equal(administrativeGroup, that.administrativeGroup) && |
| 132 | Objects.equal(ipv4InterfaceAddress, that.ipv4InterfaceAddress) && |
| 133 | Objects.equal(ipv4NeighborAddress, that.ipv4NeighborAddress) && |
| 134 | Objects.equal(maximumLinkBandwidth, that.maximumLinkBandwidth) && |
| 135 | Objects.equal(maximumReservableLinkBandwidth, |
| 136 | that.maximumReservableLinkBandwidth) && |
| 137 | Objects.equal(teDefaultMetric, that.teDefaultMetric); |
| 138 | } |
| 139 | |
| 140 | @Override |
| 141 | public int hashCode() { |
| 142 | return Objects.hashCode(administrativeGroup, ipv4InterfaceAddress, |
| 143 | ipv4NeighborAddress, maximumLinkBandwidth, teDefaultMetric); |
| 144 | } |
| 145 | } |