blob: ecd266e546329f2accaabab1ff49ac33553d978c [file] [log] [blame]
Jian Li6d2ffbf2020-11-04 15:58:18 +09001/*
2 * Copyright 2020-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.k8snode.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 * Kubernetes node info class.
26 */
27public class K8sNodeInfo {
28 private final IpAddress nodeIp;
29 private final MacAddress nodeMac;
30
31 /**
32 * Default constructor.
33 *
34 * @param nodeIp node IP address
35 * @param nodeMac node MAC address
36 */
37 public K8sNodeInfo(IpAddress nodeIp, MacAddress nodeMac) {
38 this.nodeIp = nodeIp;
39 this.nodeMac = nodeMac;
40 }
41
42 /**
43 * Obtains Kubernetes node IP address.
44 *
45 * @return node IP address
46 */
47 public IpAddress nodeIp() {
48 return nodeIp;
49 }
50
51 /**
52 * Obtains Kubernetes node MAC address.
53 *
54 * @return node MAC address
55 */
56 public MacAddress nodeMac() {
57 return nodeMac;
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 K8sNodeInfo that = (K8sNodeInfo) o;
69 return Objects.equals(nodeIp, that.nodeIp) &&
70 Objects.equals(nodeMac, that.nodeMac);
71 }
72
73 @Override
74 public int hashCode() {
75 return Objects.hash(nodeIp, nodeMac);
76 }
77
78 @Override
79 public String toString() {
80 return MoreObjects.toStringHelper(this)
81 .add("nodeIp", nodeIp)
82 .add("nodeMac", nodeMac)
83 .toString();
84 }
85}