Merge "Bug 6641: Fix ip_address in allowed_address_pairs info"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronMeteringLabel.java
index 8d292060862fec216bba4bbeb22f8360985b034b..ed25bf442e8a9a75af0d3211e7bbdccb3adbfbd3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corporation, 2015.  All rights reserved.
+ * Copyright (c) 2015 IBM Corporation and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,7 +9,8 @@
 package org.opendaylight.neutron.spi;
 
 import java.io.Serializable;
-
+import java.util.Iterator;
+import java.util.List;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -17,33 +18,20 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class NeutronMeteringLabel implements Serializable {
+public final class NeutronMeteringLabel extends NeutronObject<NeutronMeteringLabel>
+        implements Serializable, INeutronObject<NeutronMeteringLabel> {
     private static final long serialVersionUID = 1L;
 
-    @XmlElement (name = "id")
-    String meteringLabelUUID;
-
-    @XmlElement (name = "name")
+    @XmlElement(name = "name")
     String meteringLabelName;
 
-    @XmlElement (name = "tenant_id")
-    String tenantID;
-
-    @XmlElement (name = "description")
-    String description;
+    @XmlElement(defaultValue = "false", name = "shared")
+    Boolean shared;
 
     /*
      * getters and setters
      */
 
-    public String getMeteringLabelUUID() {
-        return meteringLabelUUID;
-    }
-
-    public void setMeteringLabelUUID(String uuid) {
-        this.meteringLabelUUID = uuid;
-    }
-
     public String getMeteringLabelName() {
         return meteringLabelName;
     }
@@ -52,33 +40,53 @@ public class NeutronMeteringLabel implements Serializable {
         this.meteringLabelName = name;
     }
 
-    public String getMeteringTenantID() {
-        return tenantID;
+    public Boolean getMeteringLabelShared() {
+        return shared;
     }
 
-    public void setMeteringTenantID(String tenantID) {
-        this.tenantID = tenantID;
-    }
-
-    public String getMeteringDescription() {
-        return description;
-    }
-
-    public void setMeteringDescription(String description) {
-        this.description = description;
+    public void setMeteringLabelShared(Boolean shared) {
+        this.shared = shared;
     }
 
     /*
      *  constructor
      */
-    public NeutronMeteringLabel() { }
+    public NeutronMeteringLabel() {
+    }
 
     @Override
     public String toString() {
-        return "NeutronMeteringLabel [id=" + meteringLabelUUID +
-            ", name=" + meteringLabelName +
-            ", description=" + description +
-            ", tenant_id=" + tenantID + "]";
+        return "NeutronMeteringLabel [id=" + uuid + ", name=" + meteringLabelName + ", tenant_id=" + tenantID
+                + ", shared=" + shared + "]";
     }
 
+    /**
+     * 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 a NeutronMeteringLabel object with only the selected fields
+     * populated
+     */
+    public NeutronMeteringLabel extractFields(List<String> fields) {
+        NeutronMeteringLabel ans = new NeutronMeteringLabel();
+        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.setMeteringLabelName(this.getMeteringLabelName());
+            }
+            if (s.equals("tenant_id")) {
+                ans.setTenantID(this.getTenantID());
+            }
+            if (s.equals("shared")) {
+                ans.setMeteringLabelShared(this.getMeteringLabelShared());
+            }
+        }
+        return ans;
+    }
 }