northbound: make newNeutronRequest concrete method 17/45117/2
authorIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 2 Sep 2016 22:40:48 +0000 (15:40 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Sat, 3 Sep 2016 00:09:53 +0000 (17:09 -0700)
By this change, about 120 lines are reduced.

Change-Id: Id4838b4e5109d92f01e18e611e869c27b56371e9
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
29 files changed:
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronL2gatewayConnectionNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronL2gatewayNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronQosPolicyNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCFlowClassifiersNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortChainsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortPairGroupsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortPairsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java

index 7577ad7e8ec0771ed0473e08d7ff516df9d9a410..c6102ca467cda6067e66dcbe9c3090cd1bb755c9 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.neutron.northbound.api;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.ParameterizedType;
 import java.net.HttpURLConnection;
 import java.util.List;
 import javax.ws.rs.core.Response;
@@ -36,7 +39,24 @@ public abstract class AbstractNeutronNorthbound<T extends INeutronObject<T>, Neu
 
     protected abstract String getResourceName();
 
-    protected abstract NeutronRequest newNeutronRequest(T o);
+    private NeutronRequest newNeutronRequest(T o) {
+        // return new NeutronRequest(o);
+
+        ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
+        // argumentClass = T.class
+        Class<T> argumentClass = (Class) parameterizedType.getActualTypeArguments()[0];
+        // cls = NeturonRequest.class
+        Class<NeutronRequest> cls = (Class) parameterizedType.getActualTypeArguments()[1];
+        try {
+            // ctor = NeutronRequest constructor
+            Constructor<NeutronRequest> ctor = cls.getDeclaredConstructor(argumentClass);
+            return ctor.newInstance(o);
+        } catch (NoSuchMethodException | InstantiationException
+                 | IllegalAccessException | InvocationTargetException e) {
+            // This case shouldn't happen
+            throw new RuntimeException(e);
+        }
+    }
 
     protected abstract I getNeutronCRUD();
 
index 013274d2c8a0cb3e6e0faf10cfe172c15e264ecf..5a97a9a9c5d7c676e8abcc3a31343d634e6031c8 100644 (file)
@@ -65,11 +65,6 @@ public class NeutronBgpvpnsNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronBgpvpnRequest newNeutronRequest(NeutronBgpvpn o) {
-        return new NeutronBgpvpnRequest(o);
-    }
-
     @Override
     protected INeutronBgpvpnCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronBgpvpnCRUD(this);
index 21319a63c2caf1e8f2de318abc8d1d31a3280b92..05c79bb4df30c5a1f0f62efc746ce124868757d8 100644 (file)
@@ -56,11 +56,6 @@ public class NeutronFirewallNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronFirewallRequest newNeutronRequest(NeutronFirewall o) {
-        return new NeutronFirewallRequest(o);
-    }
-
     @Override
     protected INeutronFirewallCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFirewallCRUD(this);
index 533948901bd89438c0b511d6db399f33dfdd3c22..f88bcbb54b73e67e5fe2e83201b7c43dd73c4c4b 100644 (file)
@@ -56,11 +56,6 @@ public class NeutronFirewallPolicyNorthbound extends
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronFirewallPolicyRequest newNeutronRequest(NeutronFirewallPolicy o) {
-        return new NeutronFirewallPolicyRequest(o);
-    }
-
     @Override
     protected INeutronFirewallPolicyCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFirewallPolicyCRUD(this);
index 7cf05fa764436c974acd4952d46691d5720a9b89..98c0b56d5c10a48064d6cfeb710b4df6b2421ac6 100644 (file)
@@ -55,11 +55,6 @@ public class NeutronFirewallRulesNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronFirewallRuleRequest newNeutronRequest(NeutronFirewallRule o) {
-        return new NeutronFirewallRuleRequest(o);
-    }
-
     @Override
     protected INeutronFirewallRuleCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFirewallRuleCRUD(this);
index f720f331cc466e06431e17814d085cf92bb3a3dd..bea485d429f2b60856daeff30c5a93da558d979a 100644 (file)
@@ -57,11 +57,6 @@ public class NeutronFloatingIPsNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronFloatingIPRequest newNeutronRequest(NeutronFloatingIP o) {
-        return new NeutronFloatingIPRequest(o);
-    }
-
     private NeutronCRUDInterfaces getNeutronInterfaces(boolean flag) {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFloatingIPCRUD(this);
         if (answer.getFloatingIPInterface() == null) {
index 6af81f00df49894cb01b6be9ddfb53fe7e67a206..7166a989c739f765ac0444ae0342ae561e5f3f92 100644 (file)
@@ -65,11 +65,6 @@ public class NeutronL2gatewayConnectionNorthbound extends AbstractNeutronNorthbo
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronL2gatewayConnectionRequest newNeutronRequest(NeutronL2gatewayConnection o) {
-        return new NeutronL2gatewayConnectionRequest(o);
-    }
-
     @Override
     protected INeutronL2gatewayConnectionCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronL2gatewayConnectionCRUD(this);
index 7dc5f1edd9ee1055582487edd58bb2cc634997cc..4a7f3bf074c938c82bb986a563b4eec1a2c7783c 100644 (file)
@@ -64,11 +64,6 @@ public class NeutronL2gatewayNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronL2gatewayRequest newNeutronRequest(NeutronL2gateway o) {
-        return new NeutronL2gatewayRequest(o);
-    }
-
     @Override
     protected INeutronL2gatewayCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronL2gatewayCRUD(this);
index c2728f4ab3a81ed7b64d2a814b8709245b5566ea..0a685c2a5a17178cca428cf55a6fc77240bf8a04 100644 (file)
@@ -58,11 +58,6 @@ public class NeutronLoadBalancerHealthMonitorNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronLoadBalancerHealthMonitorRequest newNeutronRequest(NeutronLoadBalancerHealthMonitor o) {
-        return new NeutronLoadBalancerHealthMonitorRequest(o);
-    }
-
     @Override
     protected INeutronLoadBalancerHealthMonitorCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronLoadBalancerHealthMonitorCRUD(this);
index a1a3059b0ad06a9fe4baac4290ae9187018b7576..f9b50760ebc920c4de6d8f5f2b4fbbc67cdd47f4 100644 (file)
@@ -57,11 +57,6 @@ public class NeutronLoadBalancerListenerNorthbound extends AbstractNeutronNorthb
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronLoadBalancerListenerRequest newNeutronRequest(NeutronLoadBalancerListener o) {
-        return new NeutronLoadBalancerListenerRequest(o);
-    }
-
     @Override
     protected INeutronLoadBalancerListenerCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronLoadBalancerListenerCRUD(this);
index 163c5268426083e0979b01df9db4d0664461dde6..41b2abcd7802a291e322389e6bdd72c980c0833e 100644 (file)
@@ -57,11 +57,6 @@ public class NeutronLoadBalancerNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronLoadBalancerRequest newNeutronRequest(NeutronLoadBalancer o) {
-        return new NeutronLoadBalancerRequest(o);
-    }
-
     @Override
     protected INeutronLoadBalancerCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronLoadBalancerCRUD(this);
index 2b7494a928a55fc9b2fe42a51f2e12cb52ef1ced..4665cb3a8301689384fa733801e33c7203b17c79 100644 (file)
@@ -64,11 +64,6 @@ public class NeutronLoadBalancerPoolNorthbound extends AbstractNeutronNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronLoadBalancerPoolRequest newNeutronRequest(NeutronLoadBalancerPool o) {
-        return new NeutronLoadBalancerPoolRequest(o);
-    }
-
     @Override
     protected INeutronLoadBalancerPoolCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronLoadBalancerPoolCRUD(this);
index 263f2b0a41d11ceac48a8aad0e4b98dfe702e7b2..4c4ce8fd7786849bcbd404339c5685220c16c071 100644 (file)
@@ -67,11 +67,6 @@ public class NeutronMeteringLabelRulesNorthbound extends AbstractNeutronNorthbou
         return answer.getMeteringLabelRuleInterface();
     }
 
-    @Override
-    protected NeutronMeteringLabelRuleRequest newNeutronRequest(NeutronMeteringLabelRule o) {
-        return new NeutronMeteringLabelRuleRequest(o);
-    }
-
     @Context
     UriInfo uriInfo;
 
index 69d44a5d8747721de83ba3b406dd1c8109d1e792..f2e837c19bb48b4e7271b93ccd968374fe60ae6a 100644 (file)
@@ -67,11 +67,6 @@ public class NeutronMeteringLabelsNorthbound extends
         return answer.getMeteringLabelInterface();
     }
 
-    @Override
-    protected NeutronMeteringLabelRequest newNeutronRequest(NeutronMeteringLabel o) {
-        return new NeutronMeteringLabelRequest(o);
-    }
-
     @Context
     UriInfo uriInfo;
 
index 05f03444bff799209c39c7f507714d909aa345c9..469aa9120a66b00f702565c308ce7de5d0c20779 100644 (file)
@@ -65,11 +65,6 @@ public class NeutronNetworksNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronNetworkRequest newNeutronRequest(NeutronNetwork o) {
-        return new NeutronNetworkRequest(o);
-    }
-
     @Override
     protected INeutronNetworkCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronNetworkCRUD(this);
index 32ef7dd6f72d518647440e3cad4735f9859ed4d2..8500145f039f337cf0b2a1958102cce4c744d6fd 100644 (file)
@@ -88,11 +88,6 @@ public class NeutronPortsNorthbound
         return getNeutronInterfaces(false, false).getPortInterface();
     }
 
-    @Override
-    protected NeutronPortRequest newNeutronRequest(NeutronPort o) {
-        return new NeutronPortRequest(o);
-    }
-
     @Context
     UriInfo uriInfo;
 
index 9060f0f33f5c5501f9802a88d45251c0910f783d..572dcde049844a5d3490eb5a379f7c8edb099cd6 100644 (file)
@@ -39,11 +39,6 @@ public class NeutronQosPolicyNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronQosPolicyRequest newNeutronRequest(NeutronQosPolicy o) {
-        return new NeutronQosPolicyRequest(o);
-    }
-
     @Override
     protected INeutronQosPolicyCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronQosPolicyCRUD(this);
index da1827f52454b64e3f7f0dda8343ff4cfe526947..b9c51d6225a5affded533460eb31d4321a0dcb71 100644 (file)
@@ -80,11 +80,6 @@ public class NeutronRoutersNorthbound
         return getNeutronInterfaces(false).getRouterInterface();
     }
 
-    @Override
-    protected NeutronRouterRequest newNeutronRequest(NeutronRouter o) {
-        return new NeutronRouterRequest(o);
-    }
-
     /**
      * Returns a list of all Routers */
 
index 3d2227180d1fd07d7219f337c34686cdb611d7c8..f9f6aa9c283baa1f5209cda282bf7be1fe463f30 100644 (file)
@@ -56,11 +56,6 @@ public class NeutronSFCFlowClassifiersNorthbound extends AbstractNeutronNorthbou
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronSFCFlowClassifierRequest newNeutronRequest(NeutronSFCFlowClassifier o) {
-        return new NeutronSFCFlowClassifierRequest(o);
-    }
-
     @Override
     protected INeutronSFCFlowClassifierCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSFCFlowClassifierCRUD(this);
index 301515a70c76ea1ea8faf709119afaf6ea7b5c1a..3d54b5bcfd16ebb6a93a5348ac83113a27ba9dcc 100644 (file)
@@ -57,11 +57,6 @@ public class NeutronSFCPortChainsNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronSFCPortChainRequest newNeutronRequest(NeutronSFCPortChain o) {
-        return new NeutronSFCPortChainRequest(o);
-    }
-
     @Override
     protected INeutronSFCPortChainCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSFCPortChainCRUD(this);
index 4b269d8adc9252215d4168ddf9cdc1c7ed808f10..c3c3a157246fbc0fc0b45879101655fe0bf5c0a6 100644 (file)
@@ -57,11 +57,6 @@ public class NeutronSFCPortPairGroupsNorthbound extends AbstractNeutronNorthboun
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronSFCPortPairGroupRequest newNeutronRequest(NeutronSFCPortPairGroup o) {
-        return new NeutronSFCPortPairGroupRequest(o);
-    }
-
     @Override
     protected INeutronSFCPortPairGroupCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSFCPortPairGroupCRUD(this);
index 475b89300d390c88188b778fdf136c3493df058d..c61fc0c0d46aba2c7120ead652f3b54ee1be05ac 100644 (file)
@@ -57,11 +57,6 @@ public class NeutronSFCPortPairsNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronSFCPortPairRequest newNeutronRequest(NeutronSFCPortPair o) {
-        return new NeutronSFCPortPairRequest(o);
-    }
-
     @Override
     protected INeutronSFCPortPairCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSFCPortPairCRUD(this);
index 77aba65d3545165ba742cd1954134e3bc4973294..9e12af17e6a4148493bede3f362778685637f4cc 100644 (file)
@@ -55,11 +55,6 @@ public class NeutronSecurityGroupsNorthbound extends
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronSecurityGroupRequest newNeutronRequest(NeutronSecurityGroup o) {
-        return new NeutronSecurityGroupRequest(o);
-    }
-
     @Override
     protected INeutronSecurityGroupCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this);
index a05790ac56e82f52158b74b9f5f723e5a72a0010..3a95c4e17078428c3a25bf110688887f9d50be28 100644 (file)
@@ -56,11 +56,6 @@ public class NeutronSecurityRulesNorthbound
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronSecurityRuleRequest newNeutronRequest(NeutronSecurityRule o) {
-        return new NeutronSecurityRuleRequest(o);
-    }
-
     @Override
     protected INeutronSecurityRuleCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSecurityRuleCRUD(this);
index 575ab926d920cf01275a9f5de9fb9d2ee7b76fd8..649a461cc269eb76c46497faa5a32fb70de25407 100644 (file)
@@ -80,11 +80,6 @@ public class NeutronSubnetsNorthbound
         return getNeutronInterfaces(false).getSubnetInterface();
     }
 
-    @Override
-    protected NeutronSubnetRequest newNeutronRequest(NeutronSubnet o) {
-        return new NeutronSubnetRequest(o);
-    }
-
     @Context
     UriInfo uriInfo;
 
index fa7bdcd849afcff776758ecaabc61800560718fd..ec886f303d961b58b0a8fa380dc3f4c512fee74f 100644 (file)
@@ -69,11 +69,6 @@ public class NeutronVPNIKEPoliciesNorthbound
         return answer.getVPNIKEPolicyInterface();
     }
 
-    @Override
-    protected NeutronVPNIKEPolicyRequest newNeutronRequest(NeutronVPNIKEPolicy o) {
-        return new NeutronVPNIKEPolicyRequest(o);
-    }
-
     @Context
     UriInfo uriInfo;
 
index 80f6176522daa494dd3c38f67f13e3ccd0d394f6..3dd4d8cb41d81887e6ab781b69f45331d0371b26 100644 (file)
@@ -70,11 +70,6 @@ public class NeutronVPNIPSECPoliciesNorthbound extends
         return answer.getVPNIPSECPolicyInterface();
     }
 
-    @Override
-    protected NeutronVPNIPSECPolicyRequest newNeutronRequest(NeutronVPNIPSECPolicy o) {
-        return new NeutronVPNIPSECPolicyRequest(o);
-    }
-
     @Context
     UriInfo uriInfo;
 
index f9a7daf34826beacf214630043886db7579a035a..055bf3af10bba256988dd28bf6fafdd0a76b8cd7 100644 (file)
@@ -61,11 +61,6 @@ public class NeutronVPNIPSECSiteConnectionsNorthbound extends AbstractNeutronNor
         return RESOURCE_NAME;
     }
 
-    @Override
-    protected NeutronVPNIPSECSiteConnectionRequest newNeutronRequest(NeutronVPNIPSECSiteConnection o) {
-        return new NeutronVPNIPSECSiteConnectionRequest(o);
-    }
-
     @Override
     protected INeutronVPNIPSECSiteConnectionsCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronVPNIPSECSiteConnectionsCRUD(this);
index 9fa3d8840699432fa16a063cd7f3a1e79277a10e..028b38c03deeace93222b158cb87c2dd226f8f81 100644 (file)
@@ -64,11 +64,6 @@ public class NeutronVPNServicesNorthbound
     @Context
     UriInfo uriInfo;
 
-    @Override
-    protected NeutronVPNServiceRequest newNeutronRequest(NeutronVPNService o) {
-        return new NeutronVPNServiceRequest(o);
-    }
-
     @Override
     protected INeutronVPNServiceCRUD getNeutronCRUD() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronVPNServiceCRUD(this);