Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 1 | /*
|
| 2 | * Copyright 2015 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.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 routeInstance routing protocol instance
|
| 38 | * @param asNum AS number
|
| 39 | * @param domainIdentifier BGP-LS domain
|
| 40 | * @param areaId Area ID
|
| 41 | * @param routerIdentifier IGP router ID
|
| 42 | */
|
| 43 | public IpDeviceIdentifier(RouteDistinguisher routeDish, RouteInstance routeInstance, AsNumber asNum,
|
| 44 | DomainId domainIdentifier, AreaId areaId, RouteIdentifier routerIdentifier) {
|
| 45 | this.routeDish = routeDish;
|
| 46 | this.areaId = areaId;
|
| 47 | this.asNum = asNum;
|
| 48 | this.domainIdentifier = domainIdentifier;
|
| 49 | this.routeInstance = routeInstance;
|
| 50 | this.routerIdentifier = routerIdentifier;
|
| 51 | }
|
| 52 |
|
| 53 | /**
|
| 54 | * Obtains Route Distinguisher of Ip Device.
|
| 55 | *
|
| 56 | * @return Area ID
|
| 57 | */
|
| 58 | public RouteDistinguisher routeDish() {
|
| 59 | return routeDish;
|
| 60 | }
|
| 61 |
|
| 62 | /**
|
| 63 | * Obtains Area ID if Ip Device.
|
| 64 | *
|
| 65 | * @return Area ID
|
| 66 | */
|
| 67 | public AreaId areaId() {
|
| 68 | return areaId;
|
| 69 | }
|
| 70 |
|
| 71 | /**
|
| 72 | * Obtains AS number of Ip Device.
|
| 73 | *
|
| 74 | * @return AS number
|
| 75 | */
|
| 76 | public AsNumber asNum() {
|
| 77 | return asNum;
|
| 78 | }
|
| 79 |
|
| 80 | /**
|
| 81 | * Obtains domain identifier of Ip Device.
|
| 82 | *
|
| 83 | * @return domain identifier
|
| 84 | */
|
| 85 | public DomainId domainIdentifier() {
|
| 86 | return domainIdentifier;
|
| 87 | }
|
| 88 |
|
| 89 | /**
|
| 90 | * Obtains Router id of Ip Device.
|
| 91 | *
|
| 92 | * @return Router id
|
| 93 | */
|
| 94 | public RouteIdentifier routerIdentifier() {
|
| 95 | return routerIdentifier;
|
| 96 | }
|
| 97 |
|
| 98 | /**
|
| 99 | * Obtains routing protocol instance.
|
| 100 | *
|
| 101 | * @return routing protocol instance
|
| 102 | */
|
| 103 | public RouteInstance routeInstance() {
|
| 104 | return routeInstance;
|
| 105 | }
|
| 106 |
|
| 107 | @Override
|
| 108 | public int hashCode() {
|
| 109 | return Objects.hash(routeDish, areaId, asNum, domainIdentifier, routerIdentifier, routeInstance);
|
| 110 | }
|
| 111 |
|
| 112 | @Override
|
| 113 | public boolean equals(Object obj) {
|
| 114 | if (this == obj) {
|
| 115 | return true;
|
| 116 | }
|
| 117 |
|
| 118 | if (obj instanceof IpDeviceIdentifier) {
|
| 119 | IpDeviceIdentifier other = (IpDeviceIdentifier) obj;
|
| 120 | return Objects.equals(areaId, other.areaId) && Objects.equals(asNum, other.asNum)
|
| 121 | && Objects.equals(domainIdentifier, other.domainIdentifier)
|
| 122 | && Objects.equals(routerIdentifier, other.routerIdentifier)
|
| 123 | && Objects.equals(routeInstance, other.routeInstance)
|
| 124 | && Objects.equals(routeDish, other.routeDish);
|
| 125 | }
|
| 126 | return false;
|
| 127 | }
|
| 128 |
|
| 129 | @Override
|
| 130 | public String toString() {
|
| 131 | return toStringHelper(this)
|
| 132 | .omitNullValues()
|
| 133 | .add("areaId", areaId)
|
| 134 | .add("asNum", asNum)
|
| 135 | .add("domainIdentifier", domainIdentifier)
|
| 136 | .add("routerIdentifier", routerIdentifier)
|
| 137 | .add("routeInstance", routeInstance)
|
| 138 | .add("routeDish", routeDish)
|
| 139 | .toString();
|
| 140 | }
|
| 141 | } |