Mohammad Shahid | aa7c123 | 2017-08-09 11:13:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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 | |
Ray Milkey | a95193c | 2017-08-10 15:35:36 -0700 | [diff] [blame] | 17 | package org.onosproject.evpnrouteservice; |
Mohammad Shahid | aa7c123 | 2017-08-09 11:13:15 +0530 | [diff] [blame] | 18 | |
| 19 | import java.util.Objects; |
| 20 | |
Ray Milkey | a95193c | 2017-08-10 15:35:36 -0700 | [diff] [blame] | 21 | import org.onlab.packet.IpAddress; |
| 22 | |
Mohammad Shahid | aa7c123 | 2017-08-09 11:13:15 +0530 | [diff] [blame] | 23 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 24 | |
| 25 | /** |
| 26 | * Represents a evpn instance nexthop. |
| 27 | */ |
| 28 | public final class EvpnInstanceNextHop { |
| 29 | |
| 30 | private final IpAddress nextHop; |
| 31 | private final Label label; |
| 32 | |
| 33 | /** |
| 34 | * Constructor to initialize the parameters. |
| 35 | * |
| 36 | * @param nextHop nexthop |
| 37 | * @param label label |
| 38 | */ |
| 39 | private EvpnInstanceNextHop(IpAddress nextHop, Label label) { |
| 40 | this.nextHop = nextHop; |
| 41 | this.label = label; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * creates instance of EvpnInstanceNextHop. |
| 46 | * |
| 47 | * @param nextHop nexthop |
| 48 | * @param label label |
| 49 | * @return evpnInstanceNexthop |
| 50 | */ |
| 51 | public static EvpnInstanceNextHop evpnNextHop(IpAddress nextHop, |
| 52 | Label label) { |
| 53 | return new EvpnInstanceNextHop(nextHop, label); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the next hop IP address. |
| 58 | * |
| 59 | * @return next hop |
| 60 | */ |
| 61 | public IpAddress nextHop() { |
| 62 | return nextHop; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the label. |
| 67 | * |
| 68 | * @return Label |
| 69 | */ |
| 70 | public Label label() { |
| 71 | return label; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public int hashCode() { |
| 76 | return Objects.hash(nextHop, label); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public boolean equals(Object other) { |
| 81 | if (this == other) { |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | if (!(other instanceof EvpnInstanceNextHop)) { |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | EvpnInstanceNextHop that = (EvpnInstanceNextHop) other; |
| 90 | |
| 91 | return Objects.equals(this.nextHop(), that.nextHop()) |
| 92 | && Objects.equals(this.label, that.label); |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public String toString() { |
| 97 | return toStringHelper(this).add("nextHop", this.nextHop()) |
| 98 | .add("label", this.label).toString(); |
| 99 | } |
| 100 | } |