blob: cb488b3d7d7ef62b114a253c8b2451425562b666 [file] [log] [blame]
Jian Li9ee9c8b2019-01-24 11:48:12 +09001/*
2 * Copyright 2019-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.k8snetworking.api;
17
18import com.google.common.base.MoreObjects;
19import com.google.common.base.Objects;
20import org.onlab.packet.IpAddress;
21
22/**
23 * Default implementation of kubernetes IPAM instance.
24 */
25public final class DefaultK8sIpam implements K8sIpam {
26
27 private final IpAddress ipAddress;
28 private final String networkId;
29
30 // private constructor not intended for external invocation
31 public DefaultK8sIpam(IpAddress ipAddress, String networkId) {
32 this.ipAddress = ipAddress;
33 this.networkId = networkId;
34 }
35
36 @Override
37 public IpAddress ipAddress() {
38 return ipAddress;
39 }
40
41 @Override
42 public String networkId() {
43 return networkId;
44 }
45
46 @Override
47 public boolean equals(Object o) {
48 if (this == o) {
49 return true;
50 }
51 if (o == null || getClass() != o.getClass()) {
52 return false;
53 }
54 DefaultK8sIpam that = (DefaultK8sIpam) o;
55 return Objects.equal(ipAddress, that.ipAddress) &&
56 Objects.equal(networkId, that.networkId);
57 }
58
59 @Override
60 public int hashCode() {
61 return Objects.hashCode(ipAddress, networkId);
62 }
63
64 @Override
65 public String toString() {
66 return MoreObjects.toStringHelper(this)
67 .add("ipAddress", ipAddress)
68 .add("networkId", networkId)
69 .toString();
70 }
71}