blob: 64f5129bdc1cb5637b5871852da5c43191a7be8b [file] [log] [blame]
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -07003 *
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 */
16package org.onosproject.vtnrsc;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Objects;
21
22import org.onlab.packet.IpAddress;
23import org.onlab.packet.IpPrefix;
24
25/**
26 * Host route dictionaries for the subnet.
27 */
28public 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}