2 * Copyright (c) 2016 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.vpnservice.itm.cli;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rev150701.transport.zones.transport.zone.SubnetsBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rev150701.transport.zones.transport.zone.SubnetsKey;
16 import org.opendaylight.yangtools.yang.binding.Augmentation;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
19 public class SubnetObject {
20 private IpAddress _gatewayIp;
21 private SubnetsKey _key;
22 private IpPrefix _prefix;
23 private java.lang.Integer _vlanId;
25 public SubnetObject(IpAddress gWIP, SubnetsKey key, IpPrefix mask, Integer vlanId) {
31 checkVlanIdRange(vlanId);
33 } catch (IllegalArgumentException e) {
34 System.out.println("Invalid VlanID. expected: 0 to 4095");
39 public IpAddress get_gatewayIp() {
43 public SubnetsKey get_key() {
47 public IpPrefix get_prefix() {
51 public java.lang.Integer get_vlanId() {
56 private volatile boolean hashValid = false;
59 public int hashCode() {
66 result = prime * result + ((_gatewayIp == null) ? 0 : _gatewayIp.hashCode());
67 result = prime * result + ((_key == null) ? 0 : _key.hashCode());
68 result = prime * result + ((_prefix == null) ? 0 : _prefix.hashCode());
69 result = prime * result + ((_vlanId == null) ? 0 : _vlanId.hashCode());
76 public boolean equals(java.lang.Object obj) {
80 if (!(obj instanceof SubnetObject)) {
83 SubnetObject other = (SubnetObject) obj;
84 if (_gatewayIp == null) {
85 if (other.get_gatewayIp() != null) {
88 } else if (!_gatewayIp.equals(other.get_gatewayIp())) {
92 if (other.get_key() != null) {
95 } else if (!_key.equals(other.get_key())) {
98 if (_prefix == null) {
99 if (other.get_prefix() != null) {
102 } else if (!_prefix.equals(other.get_prefix())) {
105 if (_vlanId == null) {
106 if (other.get_vlanId() != null) {
109 } else if (!_vlanId.equals(other.get_vlanId())) {
116 public java.lang.String toString() {
117 java.lang.StringBuilder builder = new java.lang.StringBuilder("Subnets [");
118 boolean first = true;
120 if (_gatewayIp != null) {
124 builder.append(", ");
126 builder.append("_gatewayIp=");
127 builder.append(_gatewayIp);
133 builder.append(", ");
135 builder.append("_key=");
136 builder.append(_key);
138 if (_prefix != null) {
142 builder.append(", ");
144 builder.append("_prefix=");
145 builder.append(_prefix);
147 if (_vlanId != null) {
151 builder.append(", ");
153 builder.append("_vlanId=");
154 builder.append(_vlanId);
156 return builder.append(']').toString();
159 private static void checkVlanIdRange(final int value) {
160 if (value >= 0 && value <= 4095) {
163 throw new IllegalArgumentException(String.format("Invalid range: %s, expected: [[0?4095]].", value));