Use foreach loops instead of explicit Iterators.
Use switch statements instead of mutually-exclusive if statements.
Change-Id: I2239a2f119686efc65ae062a95b4edbda99c5ded
Signed-off-by: Stephen Kitt <skitt@redhat.com>
import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import java.util.AbstractMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
return null;
}
- List<Neutron_IPs> fixedIPs;
- Iterator<Neutron_IPs> fixedIPIterator;
- Neutron_IPs ip;
-
List<NeutronPort> allPorts = neutronPortsCache.getAllPorts();
- Iterator<NeutronPort> i = allPorts.iterator();
- while (i.hasNext()) {
- NeutronPort port = i.next();
- fixedIPs = port.getFixedIPs();
- if (fixedIPs != null && fixedIPs.size() > 0) {
- fixedIPIterator = fixedIPs.iterator();
- while (fixedIPIterator.hasNext()) {
- ip = fixedIPIterator.next();
+ for (NeutronPort port : allPorts) {
+ List<Neutron_IPs> fixedIPs = port.getFixedIPs();
+ if (fixedIPs != null && !fixedIPs.isEmpty()) {
+ for (Neutron_IPs ip : fixedIPs) {
if (ip.getIpAddress().equals(ipAddr) && ip.getSubnetUUID().equals(subnetID)) {
return port.getMacAddress();
}
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronFirewall extractFields(List<String> fields) {
NeutronFirewall ans = new NeutronFirewall();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setFirewallTenantID(this.getFirewallTenantID());
- }
- if (s.equals("name")) {
- ans.setFirewallName(this.getFirewallName());
- }
- if(s.equals("description")) {
- ans.setFirewallDescription(this.getFirewallDescription());
- }
- if (s.equals("admin_state_up")) {
- ans.setFirewallAdminStateIsUp(firewallAdminStateIsUp);
- }
- if (s.equals("status")) {
- ans.setFirewallStatus(this.getFirewallStatus());
- }
- if (s.equals("shared")) {
- ans.setFirewallIsShared(firewallIsShared);
- }
- if (s.equals("firewall_policy_id")) {
- ans.setNeutronFirewallPolicyID(this.getFirewallPolicyID());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setFirewallTenantID(this.getFirewallTenantID());
+ break;
+ case "name":
+ ans.setFirewallName(this.getFirewallName());
+ break;
+ case "description":
+ ans.setFirewallDescription(this.getFirewallDescription());
+ break;
+ case "admin_state_up":
+ ans.setFirewallAdminStateIsUp(firewallAdminStateIsUp);
+ break;
+ case "status":
+ ans.setFirewallStatus(this.getFirewallStatus());
+ break;
+ case "shared":
+ ans.setFirewallIsShared(firewallIsShared);
+ break;
+ case "firewall_policy_id":
+ ans.setNeutronFirewallPolicyID(this.getFirewallPolicyID());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronFirewallPolicy extractFields(List<String> fields) {
NeutronFirewallPolicy ans = new NeutronFirewallPolicy();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setFirewallPolicyTenantID(this.getFirewallPolicyTenantID());
- }
- if (s.equals("name")) {
- ans.setFirewallPolicyName(this.getFirewallPolicyName());
- }
- if(s.equals("description")) {
- ans.setFirewallPolicyDescription(this.getFirewallPolicyDescription());
- }
- if (s.equals("shared")) {
- ans.setFirewallPolicyIsShared(firewallPolicyIsShared);
- }
- if (s.equals("firewall_rules")) {
- List<String> firewallRuleList = new ArrayList<>();
- firewallRuleList.addAll(this.getFirewallPolicyRules());
- ans.setFirewallPolicyRules(firewallRuleList);
- }
- if (s.equals("audited")) {
- ans.setFirewallPolicyIsAudited(firewallPolicyIsAudited);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setFirewallPolicyTenantID(this.getFirewallPolicyTenantID());
+ break;
+ case "name":
+ ans.setFirewallPolicyName(this.getFirewallPolicyName());
+ break;
+ case "description":
+ ans.setFirewallPolicyDescription(this.getFirewallPolicyDescription());
+ break;
+ case "shared":
+ ans.setFirewallPolicyIsShared(firewallPolicyIsShared);
+ break;
+ case "firewall_rules":
+ List<String> firewallRuleList = new ArrayList<>();
+ firewallRuleList.addAll(this.getFirewallPolicyRules());
+ ans.setFirewallPolicyRules(firewallRuleList);
+ break;
+ case "audited":
+ ans.setFirewallPolicyIsAudited(firewallPolicyIsAudited);
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronFirewallRule extractFields(List<String> fields) {
NeutronFirewallRule ans = new NeutronFirewallRule();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setFirewallRuleTenantID(this.getFirewallRuleTenantID());
- }
- if (s.equals("name")) {
- ans.setFirewallRuleName(this.getFirewallRuleName());
- }
- if (s.equals("description")) {
- ans.setFirewallRuleDescription(this.getFirewallRuleDescription());
- }
- if (s.equals("status")) {
- ans.setFirewallRuleStatus(this.getFirewallRuleStatus());
- }
- if (s.equals("shared")) {
- ans.setFirewallRuleIsShared(firewallRuleIsShared);
- }
- if (s.equals("firewall_policy_id")) {
- ans.setFirewallRulesPolicyID(this.getFirewallRulePolicyID());
- }
- if (s.equals("protocol")) {
- ans.setFirewallRuleProtocol(this.getFirewallRuleProtocol());
- }
- if (s.equals("source_ip_address")) {
- ans.setFirewallRuleSrcIpAddr(this.getFirewallRuleSrcIpAddr());
- }
- if (s.equals("destination_ip_address")) {
- ans.setFirewallRuleDstIpAddr(this.getFirewallRuleDstIpAddr());
- }
- if (s.equals("source_port")) {
- ans.setFirewallRuleSrcPort(this.getFirewallRuleSrcPort());
- }
- if (s.equals("destination_port")) {
- ans.setFirewallRuleDstPort(this.getFirewallRuleDstPort());
- }
- if (s.equals("position")) {
- ans.setFirewallRulePosition(this.getFirewallRulePosition());
- }
- if (s.equals("action")) {
- ans.setFirewallRuleAction(this.getFirewallRuleAction());
- }
- if (s.equals("enabled")) {
- ans.setFirewallRuleIsEnabled(firewallRuleIsEnabled);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setFirewallRuleTenantID(this.getFirewallRuleTenantID());
+ break;
+ case "name":
+ ans.setFirewallRuleName(this.getFirewallRuleName());
+ break;
+ case "description":
+ ans.setFirewallRuleDescription(this.getFirewallRuleDescription());
+ break;
+ case "status":
+ ans.setFirewallRuleStatus(this.getFirewallRuleStatus());
+ break;
+ case "shared":
+ ans.setFirewallRuleIsShared(firewallRuleIsShared);
+ break;
+ case "firewall_policy_id":
+ ans.setFirewallRulesPolicyID(this.getFirewallRulePolicyID());
+ break;
+ case "protocol":
+ ans.setFirewallRuleProtocol(this.getFirewallRuleProtocol());
+ break;
+ case "source_ip_address":
+ ans.setFirewallRuleSrcIpAddr(this.getFirewallRuleSrcIpAddr());
+ break;
+ case "destination_ip_address":
+ ans.setFirewallRuleDstIpAddr(this.getFirewallRuleDstIpAddr());
+ break;
+ case "source_port":
+ ans.setFirewallRuleSrcPort(this.getFirewallRuleSrcPort());
+ break;
+ case "destination_port":
+ ans.setFirewallRuleDstPort(this.getFirewallRuleDstPort());
+ break;
+ case "position":
+ ans.setFirewallRulePosition(this.getFirewallRulePosition());
+ break;
+ case "action":
+ ans.setFirewallRuleAction(this.getFirewallRuleAction());
+ break;
+ case "enabled":
+ ans.setFirewallRuleIsEnabled(firewallRuleIsEnabled);
+ break;
}
}
package org.opendaylight.ovsdb.openstack.netvirt.translator;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
public NeutronFloatingIP extractFields(List<String> fields) {
NeutronFloatingIP ans = new NeutronFloatingIP();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("floating_network_id")) {
- ans.setFloatingNetworkUUID(this.getFloatingNetworkUUID());
- }
- if (s.equals("port_id")) {
- ans.setPortUUID(this.getPortUUID());
- }
- if (s.equals("fixed_ip_address")) {
- ans.setFixedIPAddress(this.getFixedIPAddress());
- }
- if (s.equals("floating_ip_address")) {
- ans.setFloatingIPAddress(this.getFloatingIPAddress());
- }
- if (s.equals("tenant_id")) {
- ans.setTenantUUID(this.getTenantUUID());
- }
- if (s.equals("router_id")) {
- ans.setRouterUUID(this.getRouterUUID());
- }
- if (s.equals("status")) {
- ans.setStatus(this.getStatus());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "floating_network_id":
+ ans.setFloatingNetworkUUID(this.getFloatingNetworkUUID());
+ break;
+ case "port_id":
+ ans.setPortUUID(this.getPortUUID());
+ break;
+ case "fixed_ip_address":
+ ans.setFixedIPAddress(this.getFixedIPAddress());
+ break;
+ case "floating_ip_address":
+ ans.setFloatingIPAddress(this.getFloatingIPAddress());
+ break;
+ case "tenant_id":
+ ans.setTenantUUID(this.getTenantUUID());
+ break;
+ case "router_id":
+ ans.setRouterUUID(this.getRouterUUID());
+ break;
+ case "status":
+ ans.setStatus(this.getStatus());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancer extractFields(List<String> fields) {
NeutronLoadBalancer ans = new NeutronLoadBalancer();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerTenantID(this.getLoadBalancerTenantID());
- }
- if (s.equals("name")) {
- ans.setLoadBalancerName(this.getLoadBalancerName());
- }
- if(s.equals("description")) {
- ans.setLoadBalancerDescription(this.getLoadBalancerDescription());
- }
- if (s.equals("vip_address")) {
- ans.setLoadBalancerVipAddress(this.getLoadBalancerVipAddress());
- }
- if (s.equals("vip_subnet_id")) {
- ans.setLoadBalancerVipSubnetID(this.getLoadBalancerVipSubnetID());
- }
- if (s.equals("status")) {
- ans.setLoadBalancerStatus(this.getLoadBalancerStatus());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerAdminStateUp(this.getLoadBalancerAdminStateUp());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerTenantID(this.getLoadBalancerTenantID());
+ break;
+ case "name":
+ ans.setLoadBalancerName(this.getLoadBalancerName());
+ break;
+ case "description":
+ ans.setLoadBalancerDescription(this.getLoadBalancerDescription());
+ break;
+ case "vip_address":
+ ans.setLoadBalancerVipAddress(this.getLoadBalancerVipAddress());
+ break;
+ case "vip_subnet_id":
+ ans.setLoadBalancerVipSubnetID(this.getLoadBalancerVipSubnetID());
+ break;
+ case "status":
+ ans.setLoadBalancerStatus(this.getLoadBalancerStatus());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerAdminStateUp(this.getLoadBalancerAdminStateUp());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancerHealthMonitor extractFields(List<String> fields) {
NeutronLoadBalancerHealthMonitor ans = new NeutronLoadBalancerHealthMonitor();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerHealthMonitorTenantID(this.getLoadBalancerHealthMonitorTenantID());
- }
- if (s.equals("type")) {
- ans.setLoadBalancerHealthMonitorType(this.getLoadBalancerHealthMonitorType());
- }
- if (s.equals("delay")) {
- ans.setLoadBalancerHealthMonitorDelay(this.getLoadBalancerHealthMonitorDelay());
- }
- if (s.equals("timeout")) {
- ans.setLoadBalancerHealthMonitorTimeout(this.getLoadBalancerHealthMonitorTimeout());
- }
- if (s.equals("max_retries")) {
- ans.setLoadBalancerHealthMonitorMaxRetries(this.getLoadBalancerHealthMonitorMaxRetries());
- }
- if (s.equals("http_method")) {
- ans.setLoadBalancerHealthMonitorHttpMethod(this.getLoadBalancerHealthMonitorHttpMethod());
- }
- if(s.equals("url_path")) {
- ans.setLoadBalancerHealthMonitorUrlPath(this.getLoadBalancerHealthMonitorUrlPath());
- }
- if (s.equals("expected_codes")) {
- ans.setLoadBalancerHealthMonitorExpectedCodes(this.getLoadBalancerHealthMonitorExpectedCodes());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerHealthMonitorAdminStateIsUp(loadBalancerHealthMonitorAdminStateIsUp);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerHealthMonitorTenantID(this.getLoadBalancerHealthMonitorTenantID());
+ break;
+ case "type":
+ ans.setLoadBalancerHealthMonitorType(this.getLoadBalancerHealthMonitorType());
+ break;
+ case "delay":
+ ans.setLoadBalancerHealthMonitorDelay(this.getLoadBalancerHealthMonitorDelay());
+ break;
+ case "timeout":
+ ans.setLoadBalancerHealthMonitorTimeout(this.getLoadBalancerHealthMonitorTimeout());
+ break;
+ case "max_retries":
+ ans.setLoadBalancerHealthMonitorMaxRetries(this.getLoadBalancerHealthMonitorMaxRetries());
+ break;
+ case "http_method":
+ ans.setLoadBalancerHealthMonitorHttpMethod(this.getLoadBalancerHealthMonitorHttpMethod());
+ break;
+ case "url_path":
+ ans.setLoadBalancerHealthMonitorUrlPath(this.getLoadBalancerHealthMonitorUrlPath());
+ break;
+ case "expected_codes":
+ ans.setLoadBalancerHealthMonitorExpectedCodes(this.getLoadBalancerHealthMonitorExpectedCodes());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerHealthMonitorAdminStateIsUp(loadBalancerHealthMonitorAdminStateIsUp);
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancerListener extractFields(List<String> fields) {
NeutronLoadBalancerListener ans = new NeutronLoadBalancerListener();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if(s.equals("default_pool_id")) {
- ans.setNeutronLoadBalancerListenerDefaultPoolID(this.getNeutronLoadBalancerListenerDefaultPoolID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerListenerTenantID(this.getLoadBalancerListenerTenantID());
- }
- if (s.equals("name")) {
- ans.setLoadBalancerListenerName(this.getLoadBalancerListenerName());
- }
- if(s.equals("description")) {
- ans.setLoadBalancerListenerDescription(this.getLoadBalancerListenerDescription());
- }
- if (s.equals("protocol")) {
- ans.setNeutronLoadBalancerListenerProtocol(this.getNeutronLoadBalancerListenerProtocol());
- }
- if (s.equals("protocol_port")) {
- ans.setNeutronLoadBalancerListenerProtocolPort(this.getNeutronLoadBalancerListenerProtocolPort());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerListenerAdminStateIsUp(loadBalancerListenerAdminStateIsUp);
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "default_pool_id":
+ ans.setNeutronLoadBalancerListenerDefaultPoolID(this.getNeutronLoadBalancerListenerDefaultPoolID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerListenerTenantID(this.getLoadBalancerListenerTenantID());
+ break;
+ case "name":
+ ans.setLoadBalancerListenerName(this.getLoadBalancerListenerName());
+ break;
+ case "description":
+ ans.setLoadBalancerListenerDescription(this.getLoadBalancerListenerDescription());
+ break;
+ case "protocol":
+ ans.setNeutronLoadBalancerListenerProtocol(this.getNeutronLoadBalancerListenerProtocol());
+ break;
+ case "protocol_port":
+ ans.setNeutronLoadBalancerListenerProtocolPort(this.getNeutronLoadBalancerListenerProtocolPort());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerListenerAdminStateIsUp(loadBalancerListenerAdminStateIsUp);
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronLoadBalancerPool extractFields(List<String> fields) {
NeutronLoadBalancerPool ans = new NeutronLoadBalancerPool();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("tenant_id")) {
- ans.setLoadBalancerPoolTenantID(this.getLoadBalancerPoolTenantID());
- }
- if (s.equals("name")) {
- ans.setLoadBalancerPoolName(this.getLoadBalancerPoolName());
- }
- if(s.equals("description")) {
- ans.setLoadBalancerPoolDescription(this.getLoadBalancerPoolDescription());
- }
- if(s.equals("protocol")) {
- ans.setLoadBalancerPoolProtocol(this.getLoadBalancerPoolProtocol());
- }
- if (s.equals("lb_algorithm")) {
- ans.setLoadBalancerPoolLbAlgorithm(this.getLoadBalancerPoolLbAlgorithm());
- }
- if (s.equals("healthmonitor_id")) {
- ans.setNeutronLoadBalancerPoolHealthMonitorID(this.getNeutronLoadBalancerPoolHealthMonitorID());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerPoolAdminStateIsUp(loadBalancerPoolAdminStateIsUp);
- }
- if (s.equals("members")) {
- ans.setLoadBalancerPoolMembers(getLoadBalancerPoolMembers());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "tenant_id":
+ ans.setLoadBalancerPoolTenantID(this.getLoadBalancerPoolTenantID());
+ break;
+ case "name":
+ ans.setLoadBalancerPoolName(this.getLoadBalancerPoolName());
+ break;
+ case "description":
+ ans.setLoadBalancerPoolDescription(this.getLoadBalancerPoolDescription());
+ break;
+ case "protocol":
+ ans.setLoadBalancerPoolProtocol(this.getLoadBalancerPoolProtocol());
+ break;
+ case "lb_algorithm":
+ ans.setLoadBalancerPoolLbAlgorithm(this.getLoadBalancerPoolLbAlgorithm());
+ break;
+ case "healthmonitor_id":
+ ans.setNeutronLoadBalancerPoolHealthMonitorID(this.getNeutronLoadBalancerPoolHealthMonitorID());
+ break;
+ case "admin_state_up":
+ ans.setLoadBalancerPoolAdminStateIsUp(loadBalancerPoolAdminStateIsUp);
+ break;
+ case "members":
+ ans.setLoadBalancerPoolMembers(getLoadBalancerPoolMembers());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
@XmlRootElement
public NeutronLoadBalancerPoolMember extractFields(List<String> fields) {
NeutronLoadBalancerPoolMember ans = new NeutronLoadBalancerPoolMember();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("pool_id")) {
- ans.setPoolID(this.getPoolID());
- }
- if (s.equals("tenant_id")) {
- ans.setPoolMemberTenantID(this.getPoolMemberTenantID());
- }
- if (s.equals("address")) {
- ans.setPoolMemberAddress(this.getPoolMemberAddress());
- }
- if(s.equals("protocol_port")) {
- ans.setPoolMemberProtoPort(this.getPoolMemberProtoPort());
- }
- if (s.equals("admin_state_up")) {
- ans.setPoolMemberAdminStateIsUp(poolMemberAdminStateIsUp);
- }
- if(s.equals("weight")) {
- ans.setPoolMemberWeight(this.getPoolMemberWeight());
- }
- if(s.equals("subnet_id")) {
- ans.setPoolMemberSubnetID(this.getPoolMemberSubnetID());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "pool_id":
+ ans.setPoolID(this.getPoolID());
+ break;
+ case "tenant_id":
+ ans.setPoolMemberTenantID(this.getPoolMemberTenantID());
+ break;
+ case "address":
+ ans.setPoolMemberAddress(this.getPoolMemberAddress());
+ break;
+ case "protocol_port":
+ ans.setPoolMemberProtoPort(this.getPoolMemberProtoPort());
+ break;
+ case "admin_state_up":
+ ans.setPoolMemberAdminStateIsUp(poolMemberAdminStateIsUp);
+ break;
+ case "weight":
+ ans.setPoolMemberWeight(this.getPoolMemberWeight());
+ break;
+ case "subnet_id":
+ ans.setPoolMemberSubnetID(this.getPoolMemberSubnetID());
+ break;
}
}
return ans;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
public NeutronNetwork extractFields(List<String> fields) {
NeutronNetwork ans = new NeutronNetwork();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setNetworkUUID(this.getNetworkUUID());
- }
- if (s.equals("name")) {
- ans.setNetworkName(this.getNetworkName());
- }
- if (s.equals("admin_state_up")) {
- ans.setAdminStateUp(adminStateUp);
- }
- if (s.equals("status")) {
- ans.setStatus(this.getStatus());
- }
- if (s.equals("subnets")) {
- List<String> subnetList = new ArrayList<>();
- subnetList.addAll(this.getSubnets());
- ans.setSubnets(subnetList);
- }
- if (s.equals("shared")) {
- ans.setShared(shared);
- }
- if (s.equals("tenant_id")) {
- ans.setTenantID(this.getTenantID());
- }
- if (s.equals("external")) {
- ans.setRouterExternal(this.getRouterExternal());
- }
- if (s.equals("segmentation_id")) {
- ans.setProviderSegmentationID(this.getProviderSegmentationID());
- }
- if (s.equals("physical_network")) {
- ans.setProviderPhysicalNetwork(this.getProviderPhysicalNetwork());
- }
- if (s.equals("network_type")) {
- ans.setProviderNetworkType(this.getProviderNetworkType());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setNetworkUUID(this.getNetworkUUID());
+ break;
+ case "name":
+ ans.setNetworkName(this.getNetworkName());
+ break;
+ case "admin_state_up":
+ ans.setAdminStateUp(adminStateUp);
+ break;
+ case "status":
+ ans.setStatus(this.getStatus());
+ break;
+ case "subnets":
+ List<String> subnetList = new ArrayList<>();
+ subnetList.addAll(this.getSubnets());
+ ans.setSubnets(subnetList);
+ break;
+ case "shared":
+ ans.setShared(shared);
+ break;
+ case "tenant_id":
+ ans.setTenantID(this.getTenantID());
+ break;
+ case "external":
+ ans.setRouterExternal(this.getRouterExternal());
+ break;
+ case "segmentation_id":
+ ans.setProviderSegmentationID(this.getProviderSegmentationID());
+ break;
+ case "physical_network":
+ ans.setProviderPhysicalNetwork(this.getProviderPhysicalNetwork());
+ break;
+ case "network_type":
+ ans.setProviderNetworkType(this.getProviderNetworkType());
+ break;
}
}
return ans;
import java.io.Serializable;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
*/
public NeutronRouter extractFields(List<String> fields) {
NeutronRouter ans = new NeutronRouter();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setRouterUUID(this.getRouterUUID());
- }
- if (s.equals("name")) {
- ans.setName(this.getName());
- }
- if (s.equals("admin_state_up")) {
- ans.setAdminStateUp(this.getAdminStateUp());
- }
- if (s.equals("status")) {
- ans.setStatus(this.getStatus());
- }
- if (s.equals("tenant_id")) {
- ans.setTenantID(this.getTenantID());
- }
- if (s.equals("external_gateway_info")) {
- ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
- }
- if (s.equals("distributed")) {
- ans.setDistributed(this.getDistributed());
- }
- if (s.equals("gw_port_id")) {
- ans.setGatewayPortId(this.getGatewayPortId());
- }
- if (s.equals("routes")){
- ans.setRoutes(this.getRoutes());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setRouterUUID(this.getRouterUUID());
+ break;
+ case "name":
+ ans.setName(this.getName());
+ break;
+ case "admin_state_up":
+ ans.setAdminStateUp(this.getAdminStateUp());
+ break;
+ case "status":
+ ans.setStatus(this.getStatus());
+ break;
+ case "tenant_id":
+ ans.setTenantID(this.getTenantID());
+ break;
+ case "external_gateway_info":
+ ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
+ break;
+ case "distributed":
+ ans.setDistributed(this.getDistributed());
+ break;
+ case "gw_port_id":
+ ans.setGatewayPortId(this.getGatewayPortId());
+ break;
+ case "routes":
+ ans.setRoutes(this.getRoutes());
+ break;
}
}
return ans;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
public NeutronSecurityGroup extractFields(List<String> fields) {
NeutronSecurityGroup ans = new NeutronSecurityGroup ();
- Iterator<String> i = fields.iterator ();
- while (i.hasNext ()) {
- String s = i.next ();
- if (s.equals ("id")) {
- ans.setID (this.getID ());
- }
- if (s.equals ("name")) {
- ans.setSecurityGroupName (this.getSecurityGroupName ());
- }
- if (s.equals ("description")) {
- ans.setSecurityGroupDescription (this.getSecurityGroupDescription ());
- }
- if (s.equals ("tenant_id")) {
- ans.setSecurityGroupTenantID (this.getSecurityGroupTenantID ());
- }
- if (s.equals ("security_group_rules")) {
- ans.setSecurityRules (this.getSecurityRules ());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "name":
+ ans.setSecurityGroupName(this.getSecurityGroupName());
+ break;
+ case "description":
+ ans.setSecurityGroupDescription(this.getSecurityGroupDescription());
+ break;
+ case "tenant_id":
+ ans.setSecurityGroupTenantID(this.getSecurityGroupTenantID());
+ break;
+ case "security_group_rules":
+ ans.setSecurityRules(this.getSecurityRules());
+ break;
}
}
return ans;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
/**
public NeutronSecurityRule extractFields(List<String> fields) {
NeutronSecurityRule ans = new NeutronSecurityRule();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setID(this.getID());
- }
- if (s.equals("direction")) {
- ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
- }
- if (s.equals("protocol")) {
- ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
- }
- if (s.equals("port_range_min")) {
- ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
- }
- if (s.equals("port_range_max")) {
- ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
- }
- if (s.equals("ethertype")) {
- ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
- }
- if (s.equals("remote_ip_prefix")) {
- ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
- }
- if (s.equals("remote_group_id")) {
- ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
- }
- if (s.equals("security_group_id")) {
- ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
- }
- if (s.equals("tenant_id")) {
- ans.setSecurityRuleTenantID(this.getSecurityRuleTenantID());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setID(this.getID());
+ break;
+ case "direction":
+ ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
+ break;
+ case "protocol":
+ ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
+ break;
+ case "port_range_min":
+ ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
+ break;
+ case "port_range_max":
+ ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
+ break;
+ case "ethertype":
+ ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
+ break;
+ case "remote_ip_prefix":
+ ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
+ break;
+ case "remote_group_id":
+ ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
+ break;
+ case "security_group_id":
+ ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
+ break;
+ case "tenant_id":
+ ans.setSecurityRuleTenantID(this.getSecurityRuleTenantID());
+ break;
}
}
return ans;
public NeutronSubnet extractFields(List<String> fields) {
NeutronSubnet ans = new NeutronSubnet();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setSubnetUUID(this.getSubnetUUID());
- }
- if (s.equals("network_id")) {
- ans.setNetworkUUID(this.getNetworkUUID());
- }
- if (s.equals("name")) {
- ans.setName(this.getName());
- }
- if (s.equals("ip_version")) {
- ans.setIpVersion(this.getIpVersion());
- }
- if (s.equals("cidr")) {
- ans.setCidr(this.getCidr());
- }
- if (s.equals("gateway_ip")) {
- ans.setGatewayIP(this.getGatewayIP());
- }
- if (s.equals("dns_nameservers")) {
- List<String> nsList = new ArrayList<>();
- nsList.addAll(this.getDnsNameservers());
- ans.setDnsNameservers(nsList);
- }
- if (s.equals("allocation_pools")) {
- List<NeutronSubnetIPAllocationPool> aPools = new ArrayList<>();
- aPools.addAll(this.getAllocationPools());
- ans.setAllocationPools(aPools);
- }
- if (s.equals("host_routes")) {
- List<NeutronSubnet_HostRoute> hRoutes = new ArrayList<>();
- hRoutes.addAll(this.getHostRoutes());
- ans.setHostRoutes(hRoutes);
- }
- if (s.equals("enable_dhcp")) {
- ans.setEnableDHCP(this.getEnableDHCP());
- }
- if (s.equals("tenant_id")) {
- ans.setTenantID(this.getTenantID());
- }
- if (s.equals("ipv6_address_mode")) {
- ans.setIpV6AddressMode(this.getIpV6AddressMode());
- }
- if (s.equals("ipv6_ra_mode")) {
- ans.setIpV6RaMode(this.getIpV6RaMode());
+ for (String s : fields) {
+ switch (s) {
+ case "id":
+ ans.setSubnetUUID(this.getSubnetUUID());
+ break;
+ case "network_id":
+ ans.setNetworkUUID(this.getNetworkUUID());
+ break;
+ case "name":
+ ans.setName(this.getName());
+ break;
+ case "ip_version":
+ ans.setIpVersion(this.getIpVersion());
+ break;
+ case "cidr":
+ ans.setCidr(this.getCidr());
+ break;
+ case "gateway_ip":
+ ans.setGatewayIP(this.getGatewayIP());
+ break;
+ case "dns_nameservers":
+ List<String> nsList = new ArrayList<>();
+ nsList.addAll(this.getDnsNameservers());
+ ans.setDnsNameservers(nsList);
+ break;
+ case "allocation_pools":
+ List<NeutronSubnetIPAllocationPool> aPools = new ArrayList<>();
+ aPools.addAll(this.getAllocationPools());
+ ans.setAllocationPools(aPools);
+ break;
+ case "host_routes":
+ List<NeutronSubnet_HostRoute> hRoutes = new ArrayList<>();
+ hRoutes.addAll(this.getHostRoutes());
+ ans.setHostRoutes(hRoutes);
+ break;
+ case "enable_dhcp":
+ ans.setEnableDHCP(this.getEnableDHCP());
+ break;
+ case "tenant_id":
+ ans.setTenantID(this.getTenantID());
+ break;
+ case "ipv6_address_mode":
+ ans.setIpV6AddressMode(this.getIpV6AddressMode());
+ break;
+ case "ipv6_ra_mode":
+ ans.setIpV6RaMode(this.getIpV6RaMode());
+ break;
}
}
return ans;
* or assigning a gateway IP)
*/
public boolean gatewayIP_Pool_overlap() {
- Iterator<NeutronSubnetIPAllocationPool> i = allocationPools.iterator();
- while (i.hasNext()) {
- NeutronSubnetIPAllocationPool pool = i.next();
+ for (NeutronSubnetIPAllocationPool pool : allocationPools) {
if (ipVersion == IPV4_VERSION && pool.contains(gatewayIP)) {
return true;
}
*/
public String getLowAddr() {
String ans = null;
- Iterator<NeutronSubnetIPAllocationPool> i = allocationPools.iterator();
- while (i.hasNext()) {
- NeutronSubnetIPAllocationPool pool = i.next();
+ for (NeutronSubnetIPAllocationPool pool : allocationPools) {
if (ans == null) {
ans = pool.getPoolStart();
- }
- else {
+ } else {
if (ipVersion == IPV4_VERSION &&
- NeutronSubnetIPAllocationPool.convert(pool.getPoolStart()) <
- NeutronSubnetIPAllocationPool.convert(ans)) {
+ NeutronSubnetIPAllocationPool.convert(pool.getPoolStart()) <
+ NeutronSubnetIPAllocationPool.convert(ans)) {
ans = pool.getPoolStart();
}
if (ipVersion == IPV6_VERSION &&
- NeutronSubnetIPAllocationPool.convertV6(pool.getPoolStart()).compareTo(NeutronSubnetIPAllocationPool.convertV6(ans)) < 0) {
+ NeutronSubnetIPAllocationPool.convertV6(pool.getPoolStart()).compareTo(
+ NeutronSubnetIPAllocationPool.convertV6(ans)) < 0) {
ans = pool.getPoolStart();
}
- }
+ }
}
return ans;
}
assertTrue("Error, isCreated is not true for " + networkType,
bridgeConfigurationManagerImplSpy.createLocalNetwork(node, neutronNetworkMock));
- if (networkType.equals("vlan")) {
- verify(neutronNetworkMock, times(1)).getProviderNetworkType();
- } else if (networkType.equals("vxlan")) {
- verify(neutronNetworkMock, times(2)).getProviderNetworkType();
- } else if (networkType.equals("gre")) {
- verify(neutronNetworkMock, times(3)).getProviderNetworkType();
+ switch (networkType) {
+ case "vlan":
+ verify(neutronNetworkMock, times(1)).getProviderNetworkType();
+ break;
+ case "vxlan":
+ verify(neutronNetworkMock, times(2)).getProviderNetworkType();
+ break;
+ case "gre":
+ verify(neutronNetworkMock, times(3)).getProviderNetworkType();
+ break;
}
reset(neutronNetworkMock);
reset(node);