Madan Jampani | c27b6b2 | 2016-02-05 11:36:31 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Madan Jampani | c27b6b2 | 2016-02-05 11:36:31 -0800 | [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 | package org.onosproject.iptopology.api; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | /** |
| 23 | * Represents IP Device Identifiers. |
| 24 | */ |
| 25 | public class IpDeviceIdentifier { |
| 26 | |
| 27 | private final RouteDistinguisher routeDish; |
| 28 | private final RouteInstance routeInstance; |
| 29 | private final AsNumber asNum; |
| 30 | private final DomainId domainIdentifier; |
| 31 | private final AreaId areaId; |
| 32 | private final RouteIdentifier routerIdentifier; |
| 33 | |
| 34 | /** |
| 35 | * Constructor to initialize parameters. |
| 36 | * |
| 37 | * @param routeDish routing distinguisher instance |
| 38 | * @param routeInstance routing protocol instance |
| 39 | * @param asNum AS number |
| 40 | * @param domainIdentifier BGP-LS domain |
| 41 | * @param areaId Area ID |
| 42 | * @param routerIdentifier IGP router ID |
| 43 | */ |
| 44 | public IpDeviceIdentifier(RouteDistinguisher routeDish, RouteInstance routeInstance, AsNumber asNum, |
| 45 | DomainId domainIdentifier, AreaId areaId, RouteIdentifier routerIdentifier) { |
| 46 | this.routeDish = routeDish; |
| 47 | this.areaId = areaId; |
| 48 | this.asNum = asNum; |
| 49 | this.domainIdentifier = domainIdentifier; |
| 50 | this.routeInstance = routeInstance; |
| 51 | this.routerIdentifier = routerIdentifier; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Obtains Route Distinguisher of Ip Device. |
| 56 | * |
| 57 | * @return Area ID |
| 58 | */ |
| 59 | public RouteDistinguisher routeDish() { |
| 60 | return routeDish; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Obtains Area ID if Ip Device. |
| 65 | * |
| 66 | * @return Area ID |
| 67 | */ |
| 68 | public AreaId areaId() { |
| 69 | return areaId; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Obtains AS number of Ip Device. |
| 74 | * |
| 75 | * @return AS number |
| 76 | */ |
| 77 | public AsNumber asNum() { |
| 78 | return asNum; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Obtains domain identifier of Ip Device. |
| 83 | * |
| 84 | * @return domain identifier |
| 85 | */ |
| 86 | public DomainId domainIdentifier() { |
| 87 | return domainIdentifier; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Obtains Router id of Ip Device. |
| 92 | * |
| 93 | * @return Router id |
| 94 | */ |
| 95 | public RouteIdentifier routerIdentifier() { |
| 96 | return routerIdentifier; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Obtains routing protocol instance. |
| 101 | * |
| 102 | * @return routing protocol instance |
| 103 | */ |
| 104 | public RouteInstance routeInstance() { |
| 105 | return routeInstance; |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public int hashCode() { |
| 110 | return Objects.hash(routeDish, areaId, asNum, domainIdentifier, routerIdentifier, routeInstance); |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public boolean equals(Object obj) { |
| 115 | if (this == obj) { |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | if (obj instanceof IpDeviceIdentifier) { |
| 120 | IpDeviceIdentifier other = (IpDeviceIdentifier) obj; |
| 121 | return Objects.equals(areaId, other.areaId) && Objects.equals(asNum, other.asNum) |
| 122 | && Objects.equals(domainIdentifier, other.domainIdentifier) |
| 123 | && Objects.equals(routerIdentifier, other.routerIdentifier) |
| 124 | && Objects.equals(routeInstance, other.routeInstance) |
| 125 | && Objects.equals(routeDish, other.routeDish); |
| 126 | } |
| 127 | return false; |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public String toString() { |
| 132 | return toStringHelper(this) |
| 133 | .omitNullValues() |
| 134 | .add("areaId", areaId) |
| 135 | .add("asNum", asNum) |
| 136 | .add("domainIdentifier", domainIdentifier) |
| 137 | .add("routerIdentifier", routerIdentifier) |
| 138 | .add("routeInstance", routeInstance) |
| 139 | .add("routeDish", routeDish) |
| 140 | .toString(); |
| 141 | } |
Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 142 | } |