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 | * This class provides Prefix Identifier details.
|
| 24 | */
|
| 25 | public class PrefixIdentifier {
|
| 26 | private final TopologyId topologyId;
|
| 27 | private final RouteType routeType;
|
| 28 | private final IpReachability ipReach;
|
| 29 |
|
| 30 | /**
|
| 31 | * Constructor to initialize its parameters.
|
| 32 | *
|
| 33 | * @param topologyId topology ID of prefix
|
| 34 | * @param routeType OSPF Route type of the prefix
|
| 35 | * @param ipReach IP address prefix reachability information
|
| 36 | */
|
| 37 | public PrefixIdentifier(TopologyId topologyId, RouteType routeType, IpReachability ipReach) {
|
| 38 | this.topologyId = topologyId;
|
| 39 | this.routeType = routeType;
|
| 40 | this.ipReach = ipReach;
|
| 41 | }
|
| 42 |
|
| 43 | /**
|
| 44 | * Provides topology ID of prefix.
|
| 45 | *
|
| 46 | * @return topology id
|
| 47 | */
|
| 48 | public TopologyId topologyId() {
|
| 49 | return this.topologyId;
|
| 50 | }
|
| 51 |
|
| 52 | /**
|
| 53 | * Provides IP address prefix reachability information.
|
| 54 | *
|
| 55 | * @return IP address prefix
|
| 56 | */
|
| 57 | public IpReachability ipReach() {
|
| 58 | return this.ipReach;
|
| 59 | }
|
| 60 |
|
| 61 | /**
|
| 62 | * Provides OSPF Route type of the prefix.
|
| 63 | *
|
| 64 | * @return Route type
|
| 65 | */
|
| 66 | public RouteType routeType() {
|
| 67 | return this.routeType;
|
| 68 | }
|
| 69 |
|
| 70 | @Override
|
| 71 | public int hashCode() {
|
| 72 | return Objects.hash(topologyId, routeType, ipReach);
|
| 73 | }
|
| 74 |
|
| 75 | @Override
|
| 76 | public boolean equals(Object obj) {
|
| 77 | if (this == obj) {
|
| 78 | return true;
|
| 79 | }
|
| 80 |
|
| 81 | if (obj instanceof PrefixIdentifier) {
|
| 82 | PrefixIdentifier other = (PrefixIdentifier) obj;
|
| 83 | return Objects.equals(topologyId, other.topologyId) && Objects.equals(routeType, other.routeType)
|
| 84 | && Objects.equals(ipReach, other.ipReach);
|
| 85 | }
|
| 86 | return false;
|
| 87 | }
|
| 88 |
|
| 89 | @Override
|
| 90 | public String toString() {
|
| 91 | return toStringHelper(this)
|
| 92 | .omitNullValues()
|
| 93 | .add("routeType", routeType)
|
| 94 | .add("ipReach", ipReach)
|
| 95 | .add("topologyId", topologyId)
|
| 96 | .toString();
|
| 97 | }
|
| 98 | } |