CNlucius | 5b2fff1 | 2015-08-20 14:13:46 +0800 | [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.vtnrsc;
|
| 17 |
|
| 18 | import static com.google.common.base.MoreObjects.toStringHelper;
|
| 19 |
|
| 20 | import java.util.Objects;
|
| 21 |
|
| 22 | import org.onlab.packet.IpAddress;
|
| 23 | import org.onlab.packet.IpPrefix;
|
| 24 |
|
| 25 | /**
|
| 26 | * Host route dictionaries for the subnet.
|
| 27 | */
|
| 28 | public final class DefaultHostRoute implements HostRoute {
|
| 29 |
|
| 30 | private final IpAddress nexthop;
|
| 31 | private final IpPrefix destination;
|
| 32 |
|
| 33 | /**
|
| 34 | *
|
| 35 | * Creates a DefaultHostRoute by using the next hop and the destination.
|
| 36 | *
|
| 37 | * @param nexthop of the DefaultHostRoute
|
| 38 | * @param destination of the DefaultHostRoute
|
| 39 | */
|
| 40 | public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) {
|
| 41 | this.nexthop = nexthop;
|
| 42 | this.destination = destination;
|
| 43 | }
|
| 44 |
|
| 45 | @Override
|
| 46 | public IpAddress nexthop() {
|
| 47 | return nexthop;
|
| 48 | }
|
| 49 |
|
| 50 | @Override
|
| 51 | public IpPrefix destination() {
|
| 52 | return destination;
|
| 53 | }
|
| 54 |
|
| 55 | @Override
|
| 56 | public String toString() {
|
| 57 | return toStringHelper(this).add("nexthop", nexthop)
|
| 58 | .add("destination", destination).toString();
|
| 59 | }
|
| 60 |
|
| 61 | @Override
|
| 62 | public int hashCode() {
|
| 63 | return Objects.hash(nexthop, destination);
|
| 64 | }
|
| 65 |
|
| 66 | @Override
|
| 67 | public boolean equals(Object obj) {
|
| 68 | if (this == obj) {
|
| 69 | return true;
|
| 70 | }
|
| 71 | if (obj instanceof DefaultHostRoute) {
|
| 72 | final DefaultHostRoute other = (DefaultHostRoute) obj;
|
| 73 | return Objects.equals(this.nexthop, other.nexthop)
|
| 74 | && Objects.equals(this.destination, other.destination);
|
| 75 | }
|
| 76 | return false;
|
| 77 | }
|
| 78 |
|
| 79 | }
|