Merge "neutron-spi: sprinkle final to concrete class"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronSecurityGroup.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.neutron.spi;
10
11 import java.io.Serializable;
12 import java.util.Iterator;
13 import java.util.List;
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
18
19 /**
20  * OpenStack Neutron v2.0 Security Group bindings.
21  * See OpenStack Network API v2.0 Reference for description of
22  * annotated attributes. The current fields are as follows:
23  * <p>
24  * id                   uuid-str unique ID for the security group.
25  * name                 String name of the security group.
26  * tenant_id            uuid-str Owner of security rule..
27  */
28
29 @XmlRootElement
30 @XmlAccessorType(XmlAccessType.NONE)
31 public final class NeutronSecurityGroup extends NeutronObject<NeutronSecurityGroup>
32         implements Serializable, INeutronObject<NeutronSecurityGroup> {
33     private static final long serialVersionUID = 1L;
34
35     @XmlElement(name = "name")
36     String securityGroupName;
37
38     public NeutronSecurityGroup() {
39     }
40
41     public String getSecurityGroupName() {
42         return securityGroupName;
43     }
44
45     public void setSecurityGroupName(String securityGroupName) {
46         this.securityGroupName = securityGroupName;
47     }
48
49     public NeutronSecurityGroup extractFields(List<String> fields) {
50         NeutronSecurityGroup ans = new NeutronSecurityGroup();
51         Iterator<String> i = fields.iterator();
52         while (i.hasNext()) {
53             String s = i.next();
54             if (s.equals("id")) {
55                 ans.setID(this.getID());
56             }
57             if (s.equals("name")) {
58                 ans.setSecurityGroupName(this.getSecurityGroupName());
59             }
60             if (s.equals("tenant_id")) {
61                 ans.setTenantID(this.getTenantID());
62             }
63         }
64         return ans;
65     }
66
67     @Override
68     public String toString() {
69         return "NeutronSecurityGroup{" + "securityGroupUUID='" + uuid + '\'' + ", securityGroupName='"
70                 + securityGroupName + '\'' + ", securityGroupTenantID='" + tenantID + '\'' + "]";
71     }
72
73     @Override
74     public void initDefaults() {
75         //TODO verify no defaults values are nessecary required.
76     }
77 }