NEUTRON-162: vlan_transparent attribute is missing in network_attributes
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronRouter.java
index 6c296204a2f6e5233dc4dad63da2455cdd963033..cf49da79e51beef93b165f93bd207918114d9188 100644 (file)
@@ -8,12 +8,7 @@
 
 package org.opendaylight.neutron.spi;
 
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -21,86 +16,31 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronRouter extends NeutronObject implements Serializable, INeutronObject {
+public final class NeutronRouter extends NeutronAdminAttributes<NeutronRouter> {
     private static final long serialVersionUID = 1L;
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
-    @XmlElement (name = "name")
-    String name;
-
-    @XmlElement (defaultValue = "true", name = "admin_state_up")
-    Boolean adminStateUp;
-
-    @XmlElement (name = "status")
-    String status;
-
-    @XmlElement (name = "external_gateway_info", nillable = true)
-    NeutronRouter_NetworkReference externalGatewayInfo;
+    @XmlElement(name = "external_gateway_info", nillable = true)
+    NeutronRouterNetworkReference externalGatewayInfo;
 
-    @XmlElement (name = "distributed")
+    @XmlElement(name = "distributed")
     Boolean distributed;
 
-    @XmlElement (name = "gw_port_id", nillable = true)
+    @XmlElement(name = "gw_port_id", nillable = true)
     String gatewayPortId;
 
-    @XmlElement (name = "routes")
+    @XmlElement(name = "routes")
     List<NeutronRoute> routes;
 
-    /* Holds a map of OpenStackRouterInterfaces by subnet UUID
-     * used for internal mapping to DOVE
-     */
-    Map<String, NeutronRouter_Interface> interfaces;
-
     public NeutronRouter() {
-        interfaces = new HashMap<String, NeutronRouter_Interface>();
-    }
-
-    @Deprecated
-    public String getRouterUUID() {
-        return getID();
-    }
-
-    @Deprecated
-    public void setRouterUUID(String uuid) {
-        setID(uuid);
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public boolean isAdminStateUp() {
-        if (adminStateUp == null) {
-            return true;
-        }
-        return adminStateUp;
-    }
-
-    public Boolean getAdminStateUp() { return adminStateUp; }
-
-    public void setAdminStateUp(Boolean newValue) {
-        adminStateUp = newValue;
     }
 
-    public String getStatus() {
-        return status;
-    }
-
-    public void setStatus(String status) {
-        this.status = status;
-    }
-
-    public NeutronRouter_NetworkReference getExternalGatewayInfo() {
+    public NeutronRouterNetworkReference getExternalGatewayInfo() {
         return externalGatewayInfo;
     }
 
-    public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
+    public void setExternalGatewayInfo(NeutronRouterNetworkReference externalGatewayInfo) {
         this.externalGatewayInfo = externalGatewayInfo;
     }
 
@@ -128,86 +68,32 @@ public class NeutronRouter extends NeutronObject implements Serializable, INeutr
         this.routes = routes;
     }
 
-    /**
-     * This method copies selected fields from the object and returns them
-     * as a new object, suitable for marshaling.
-     *
-     * @param fields
-     *            List of attributes to be extracted
-     * @return an OpenStackRouters object with only the selected fields
-     * populated
-     */
-    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.setID(this.getID());
-            }
-            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")) {
+    @Override
+    protected boolean extractField(String field, NeutronRouter ans) {
+        switch (field) {
+            case "external_gateway_info":
                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
-            }
-            if (s.equals("distributed")) {
+                break;
+            case "distributed":
                 ans.setDistributed(this.getDistributed());
-            }
-            if (s.equals("gw_port_id")) {
+                break;
+            case "gw_port_id":
                 ans.setGatewayPortId(this.getGatewayPortId());
-            }
-            if (s.equals("routes")){
+                break;
+            case "routes":
                 ans.setRoutes(this.getRoutes());
-            }
+                break;
+            default:
+                return super.extractField(field, ans);
         }
-        return ans;
-    }
-
-    public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
-        interfaces = input;
-    }
-
-    public Map<String, NeutronRouter_Interface> getInterfaces() {
-        return interfaces;
-    }
-
-    public void addInterface(String s, NeutronRouter_Interface i) {
-        interfaces.put(s, i);
-    }
-
-    public void removeInterface(String s) {
-        interfaces.remove(s);
-    }
-
-    @Override
-    public void initDefaults() {
-        adminStateUp = true;
+        return true;
     }
 
     @Override
     public String toString() {
-        return "NeutronRouter [" +
-            "id=" + uuid +
-            ", name=" + name +
-            ", adminStateUp=" + adminStateUp +
-            ", status=" + status +
-            ", tenantID=" + tenantID +
-            ", external_gateway_info=" + externalGatewayInfo +
-            ", distributed=" + distributed +
-            ", gw_port_id=" + gatewayPortId +
-            ", routes=" + routes +
-            ", interfaces=" + interfaces +
-            "]";
+        return "NeutronRouter [" + "id=" + uuid + ", name=" + name + ", adminStateUp=" + adminStateUp + ", status="
+                + status + ", tenantID=" + tenantID + ", external_gateway_info=" + externalGatewayInfo
+                + ", distributed=" + distributed + ", gw_port_id=" + gatewayPortId + ", routes=" + routes + "]";
     }
 
 }