blob: b435cd6d57cc0c42f2cc7190bfbdc05f5157f1af [file] [log] [blame]
Jian Li3e81b182021-01-11 02:35:06 +09001/*
2 * Copyright 2021-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 */
16package org.onosproject.kubevirtnetworking.api;
17
18import com.google.common.base.MoreObjects;
19import org.onlab.packet.IpAddress;
20import org.onlab.packet.IpPrefix;
21
22import java.util.Objects;
23
24/**
25 * HostRoute class.
26 */
27public class KubevirtHostRoute {
28 private final IpPrefix destination;
29 private final IpAddress nexthop;
30
31 /**
32 * Default constructor.
33 *
34 * @param destination destination CIDR
35 * @param nexthop nexthop IP address
36 */
37 public KubevirtHostRoute(IpPrefix destination, IpAddress nexthop) {
38 this.destination = destination;
39 this.nexthop = nexthop;
40 }
41
42 /**
43 * Returns the destination CIDR.
44 *
45 * @return destination CIDR
46 */
Jian Lifeb84802021-01-12 16:34:49 +090047 public IpPrefix destination() {
Jian Li3e81b182021-01-11 02:35:06 +090048 return destination;
49 }
50
51 /**
52 * Returns the nexthop IP address.
53 *
54 * @return nexthop IP address
55 */
Jian Lifeb84802021-01-12 16:34:49 +090056 public IpAddress nexthop() {
Jian Li3e81b182021-01-11 02:35:06 +090057 return nexthop;
58 }
59
60 @Override
61 public boolean equals(Object o) {
62 if (this == o) {
63 return true;
64 }
65 if (o == null || getClass() != o.getClass()) {
66 return false;
67 }
68 KubevirtHostRoute kubevirtHostRoute = (KubevirtHostRoute) o;
69 return destination.equals(kubevirtHostRoute.destination) &&
70 nexthop.equals(kubevirtHostRoute.nexthop);
71 }
72
73 @Override
74 public int hashCode() {
75 return Objects.hash(destination, nexthop);
76 }
77
78 @Override
79 public String toString() {
80 return MoreObjects.toStringHelper(this)
81 .add("destination", destination)
82 .add("nexthop", nexthop)
83 .toString();
84 }
85}