blob: 00dbc2f31e8783ebea9d5f151539c623250a5a80 [file] [log] [blame]
Jian Li70c32de2021-02-26 18:15:20 +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.MacAddress;
21
22import java.util.Objects;
23
24/**
25 * External peer router class.
26 */
27public class KubevirtPeerRouter {
28
29 private final IpAddress ipAddress;
30 private final MacAddress macAddress;
31
32 /**
33 * A default constructor.
34 *
35 * @param ipAddress IP address
36 * @param macAddress MAC address
37 */
38 KubevirtPeerRouter(IpAddress ipAddress, MacAddress macAddress) {
39 this.ipAddress = ipAddress;
40 this.macAddress = macAddress;
41 }
42
43 /**
44 * Obtains the peer router IP address.
45 * @return IP address
46 */
47 public IpAddress ipAddress() {
48 return ipAddress;
49 }
50
51 /**
52 * Obtains the peer router MAC address.
53 *
54 * @return MAC address
55 */
56 public MacAddress macAddress() {
57 return macAddress;
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 KubevirtPeerRouter that = (KubevirtPeerRouter) o;
69 return ipAddress.equals(that.ipAddress) && macAddress.equals(that.macAddress);
70 }
71
72 @Override
73 public int hashCode() {
74 return Objects.hash(ipAddress, macAddress);
75 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(this)
80 .add("ipAddress", ipAddress)
81 .add("macAddress", macAddress)
82 .toString();
83 }
84}