@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((externalIP == null) ? 0 : externalIP.hashCode()); result = prime * result + externalPort; result = prime * result + internalPort; result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.hashCode()); result = prime * result + vmNicId; return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; VmRule other = (VmRule) obj; if (externalIP == null) { if (other.externalIP != null) return false; } else if (!externalIP.equals(other.externalIP)) return false; if (externalPort != other.externalPort) return false; if (internalPort != other.internalPort) return false; if (protocol == null) { if (other.protocol != null) return false; } else if (!protocol.equals(other.protocol)) return false; if (vAppScopedLocalId == null) { if (other.vAppScopedLocalId != null) return false; } else if (!vAppScopedLocalId.equals(other.vAppScopedLocalId)) return false; if (vmNicId != other.vmNicId) return false; return true; }
public void endElement(String uri, String name, String qName) { taskHandler.endElement(uri, name, qName); if (qName.equals("Task")) { this.tasks.add(taskHandler.getResult()); } else if (qName.equals("Description")) { if (inFirewallRule) firewallRuleDescription = currentOrNull(); else orgDescription = currentOrNull(); } else if (qName.equals("FenceMode")) { fenceMode = FenceMode.fromValue(currentOrNull()); } else if (qName.equals("StartAddress")) { startAddress = currentOrNull(); } else if (qName.equals("EndAddress")) { endAddress = currentOrNull(); } else if (qName.equals("AllocatedIpAddress")) { allocatedIpAddresses.add(currentOrNull()); } else if (qName.equals("IpRange")) { ipRanges.add(new IpRange(startAddress, endAddress)); this.startAddress = null; this.endAddress = null; } else if (qName.equals("IsInherited")) { inherited = Boolean.parseBoolean(currentOrNull()); } else if (qName.equals("Gateway")) { gateway = currentOrNull(); } else if (qName.equals("Netmask")) { netmask = currentOrNull(); } else if (qName.equals("Dns1")) { dns1 = currentOrNull(); } else if (qName.equals("Dns2")) { dns2 = currentOrNull(); } else if (qName.equals("DnsSuffix")) { dnsSuffix = currentOrNull(); } else if (qName.equals("IpScope")) { ipScope = new IpScope( inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses); this.inherited = false; this.gateway = null; this.netmask = null; this.dns1 = null; this.dns2 = null; this.dnsSuffix = null; this.ipRanges = Sets.newLinkedHashSet(); this.allocatedIpAddresses = Sets.newLinkedHashSet(); } else if (qName.equals("IsEnabled")) { if (inFirewallRule) firewallRuleEnabled = Boolean.parseBoolean(currentOrNull()); else serviceEnabled = Boolean.parseBoolean(currentOrNull()); } else if (qName.equals("DefaultLeaseTime")) { defaultLeaseTime = Integer.parseInt(currentOrNull()); } else if (qName.equals("MaxLeaseTime")) { maxLeaseTime = Integer.parseInt(currentOrNull()); } else if (qName.equals("DhcpService")) { this.dhcpService = new DhcpService( serviceEnabled, defaultLeaseTime, maxLeaseTime, Iterables.getOnlyElement(ipRanges)); this.serviceEnabled = false; this.defaultLeaseTime = null; this.maxLeaseTime = null; this.ipRanges = Sets.newLinkedHashSet(); } else if (qName.equals("Policy")) { if (inFirewallRule) firewallPolicy = FirewallPolicy.fromValue(currentOrNull()); else natPolicy = NatPolicy.fromValue(currentOrNull()); } else if (qName.equals("Tcp")) { tcp = Boolean.parseBoolean(currentOrNull()); } else if (qName.equals("Udp")) { udp = Boolean.parseBoolean(currentOrNull()); } else if (qName.equals("Protocols")) { this.protocols = new FirewallProtocols(tcp, udp); this.tcp = false; this.udp = false; } else if (qName.equals("DestinationIp")) { this.destinationIp = currentOrNull(); } else if (qName.equals("FirewallRule")) { this.inFirewallRule = false; this.firewallRules.add( new FirewallRule( firewallRuleEnabled, firewallRuleDescription, firewallPolicy, protocols, port, destinationIp)); this.firewallRuleEnabled = false; this.firewallRuleDescription = null; this.firewallPolicy = null; this.protocols = null; this.port = -1; this.destinationIp = null; } else if (qName.equals("FirewallService")) { firewallService = new FirewallService(serviceEnabled, firewallRules); this.serviceEnabled = false; this.firewallRules = Lists.newArrayList(); } else if (qName.equals("NatType")) { natType = NatType.fromValue(currentOrNull()); } else if (qName.equals("MappingMode")) { mappingMode = MappingMode.fromValue(currentOrNull()); } else if (qName.equalsIgnoreCase("ExternalIP")) { externalIP = currentOrNull(); } else if (qName.equalsIgnoreCase("VAppScopedVmId")) { vAppScopedVmId = currentOrNull(); } else if (qName.equalsIgnoreCase("VAppScopedLocalId")) { vAppScopedLocalId = currentOrNull(); } else if (qName.equalsIgnoreCase("vmNicId")) { vmNicId = Integer.parseInt(currentOrNull()); } else if (qName.equals("OneToOneVmRule")) { natRules.add(new OneToOneVmRule(mappingMode, externalIP, vAppScopedVmId, vmNicId)); this.mappingMode = null; this.externalIP = null; this.vAppScopedVmId = null; this.vmNicId = -1; } else if (qName.equalsIgnoreCase("ExternalPort")) { externalPort = Integer.parseInt(currentOrNull()); } else if (qName.equalsIgnoreCase("IxternalIP")) { internalIP = currentOrNull(); } else if (qName.equalsIgnoreCase("InternalPort")) { internalPort = Integer.parseInt(currentOrNull()); } else if (qName.equals("NatProtocol")) { natProtocol = NatProtocol.valueOf(currentOrNull()); } else if (qName.equals("PortForwardingRule")) { natRules.add( new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, natProtocol)); this.externalIP = null; this.externalPort = -1; this.internalIP = null; this.internalPort = -1; this.natProtocol = null; } else if (qName.equals("VmRule")) { natRules.add( new VmRule( externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, natProtocol)); this.externalIP = null; this.externalPort = -1; this.vAppScopedLocalId = null; this.vmNicId = -1; this.internalPort = -1; this.natProtocol = null; } else if (qName.equals("NatService")) { this.natService = new NatService(serviceEnabled, natType, natPolicy, natRules); this.serviceEnabled = false; this.natType = null; this.natPolicy = null; this.natRules = Lists.newArrayList(); } else if (qName.equals("Features")) { this.features = new Features(dhcpService, firewallService, natService); this.dhcpService = null; this.firewallService = null; this.natService = null; } else if (qName.equals("Configuration")) { configuration = new OrgNetworkImpl.ConfigurationImpl(ipScope, parentNetwork, fenceMode, features); this.ipScope = null; this.parentNetwork = null; this.fenceMode = null; this.features = null; } else if (qName.equals("AllowedExternalIpAddress")) { allowedExternalIpAddresses.add(currentOrNull()); } currentText = new StringBuilder(); }