blob: 64874fdfb68ea48ff595d792a6ba940222be2c2b [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;
20
21import java.util.Objects;
22
23/**
24 * Kubevirt IP Pool.
25 */
26public class KubevirtIpPool {
27
28 private final IpAddress start;
29 private final IpAddress end;
30
31 /**
32 * Default constructor.
33 *
34 * @param start start address of IP pool
35 * @param end end address of IP pool
36 */
37 public KubevirtIpPool(IpAddress start, IpAddress end) {
38 this.start = start;
39 this.end = end;
40 }
41
42 /**
43 * Returns the start address of IP pool.
44 *
45 * @return start address of IP pool
46 */
Jian Lifeb84802021-01-12 16:34:49 +090047 public IpAddress start() {
Jian Li3e81b182021-01-11 02:35:06 +090048 return start;
49 }
50
51 /**
52 * Returns the end address of IP pool.
53 *
54 * @return end address of IP pool
55 */
Jian Lifeb84802021-01-12 16:34:49 +090056 public IpAddress end() {
Jian Li3e81b182021-01-11 02:35:06 +090057 return end;
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 KubevirtIpPool that = (KubevirtIpPool) o;
69 return start.equals(that.start) && end.equals(that.end);
70 }
71
72 @Override
73 public int hashCode() {
74 return Objects.hash(start, end);
75 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(this)
80 .add("start", start)
81 .add("end", end)
82 .toString();
83 }
84}