2 * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.itm.cli;
10 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 public class SubnetObject {
17 private IpAddress gatewayIp;
18 private SubnetsKey key;
19 private IpPrefix prefix;
20 private java.lang.Integer vlanId;
21 private static final Logger LOG = LoggerFactory.getLogger(SubnetObject.class);
23 public SubnetObject(IpAddress gwIP, SubnetsKey key, IpPrefix mask, Integer vlanId) {
29 checkVlanIdRange(vlanId);
31 } catch (IllegalArgumentException e) {
32 LOG.error("Invalid VlanID. expected: 0 to 4095");
37 public IpAddress get_gatewayIp() {
41 public SubnetsKey get_key() {
45 public IpPrefix get_prefix() {
49 public java.lang.Integer get_vlanId() {
54 private volatile boolean hashValid = false;
57 public int hashCode() {
64 result = prime * result + ((gatewayIp == null) ? 0 : gatewayIp.hashCode());
65 result = prime * result + ((key == null) ? 0 : key.hashCode());
66 result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
67 result = prime * result + ((vlanId == null) ? 0 : vlanId.hashCode());
74 public boolean equals(java.lang.Object obj) {
78 if (!(obj instanceof SubnetObject)) {
81 SubnetObject other = (SubnetObject) obj;
82 if (gatewayIp == null) {
83 if (other.get_gatewayIp() != null) {
86 } else if (!gatewayIp.equals(other.get_gatewayIp())) {
90 if (other.get_key() != null) {
93 } else if (!key.equals(other.get_key())) {
97 if (other.get_prefix() != null) {
100 } else if (!prefix.equals(other.get_prefix())) {
103 if (vlanId == null) {
104 if (other.get_vlanId() != null) {
107 } else if (!vlanId.equals(other.get_vlanId())) {
114 public java.lang.String toString() {
115 java.lang.StringBuilder builder = new java.lang.StringBuilder("Subnets [");
116 boolean first = true;
118 if (gatewayIp != null) {
122 builder.append(", ");
124 builder.append("gatewayIp=");
125 builder.append(gatewayIp);
131 builder.append(", ");
133 builder.append("key=");
136 if (prefix != null) {
140 builder.append(", ");
142 builder.append("prefix=");
143 builder.append(prefix);
145 if (vlanId != null) {
149 builder.append(", ");
151 builder.append("vlanId=");
152 builder.append(vlanId);
154 return builder.append(']').toString();
157 private static void checkVlanIdRange(final int value) {
158 if (value >= 0 && value <= 4095) {
161 throw new IllegalArgumentException(String.format("Invalid range: %s, expected: [[0?4095]].", value));