Fix FindBugs violations
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronSecurityRule.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 javax.xml.bind.annotation.XmlAccessType;
12 import javax.xml.bind.annotation.XmlAccessorType;
13 import javax.xml.bind.annotation.XmlElement;
14 import javax.xml.bind.annotation.XmlRootElement;
15
16 /**
17  * See OpenStack Network API v2.0 Reference for description of
18  * annotated attributes. The current fields are as follows:
19  *
20  * <p>
21  * id                uuid (String) UUID for the security group rule.
22  * direction         String Direction the VM traffic  (ingress/egress).
23  * security_group_id The security group to associate rule with.
24  * protocol          String IP Protocol (icmp, tcp, udp, etc) or uint8.
25  * port_range_min    Integer Port at start of range
26  * port_range_max    Integer Port at end of range
27  * ethertype         String ethertype in L2 packet (IPv4, IPv6, etc)
28  * remote_ip_prefix  String (IP cidr) CIDR for address range.
29  * remote_group_id   uuid-str Source security group to apply to rule.
30  * tenant_id         uuid-str Owner of security rule. Admin only outside tenant.
31  */
32
33 @XmlRootElement
34 @XmlAccessorType(XmlAccessType.NONE)
35 public final class NeutronSecurityRule extends NeutronObject<NeutronSecurityRule> {
36     private static final long serialVersionUID = 1L;
37
38     @XmlElement(name = "direction")
39     String securityRuleDirection;
40
41     @XmlElement(name = "protocol")
42     String securityRuleProtocol;
43
44     @XmlElement(name = "port_range_min")
45     Integer securityRulePortMin;
46
47     @XmlElement(name = "port_range_max")
48     Integer securityRulePortMax;
49
50     @XmlElement(name = "ethertype")
51     String securityRuleEthertype;
52
53     @XmlElement(name = "remote_ip_prefix")
54     String securityRuleRemoteIpPrefix;
55
56     @XmlElement(name = "remote_group_id")
57     String securityRemoteGroupID;
58
59     @XmlElement(name = "security_group_id")
60     String securityRuleGroupID;
61
62     public NeutronSecurityRule() {
63     }
64
65     public String getSecurityRuleDirection() {
66         return securityRuleDirection;
67     }
68
69     public void setSecurityRuleDirection(String securityRuleDirection) {
70         this.securityRuleDirection = securityRuleDirection;
71     }
72
73     public String getSecurityRuleProtocol() {
74         return securityRuleProtocol;
75     }
76
77     public void setSecurityRuleProtocol(String securityRuleProtocol) {
78         this.securityRuleProtocol = securityRuleProtocol;
79     }
80
81     public Integer getSecurityRulePortMin() {
82         return securityRulePortMin;
83     }
84
85     public void setSecurityRulePortMin(Integer securityRulePortMin) {
86         this.securityRulePortMin = securityRulePortMin;
87     }
88
89     public Integer getSecurityRulePortMax() {
90         return securityRulePortMax;
91     }
92
93     public void setSecurityRulePortMax(Integer securityRulePortMax) {
94         this.securityRulePortMax = securityRulePortMax;
95     }
96
97     public String getSecurityRuleEthertype() {
98         return securityRuleEthertype;
99     }
100
101     public void setSecurityRuleEthertype(String securityRuleEthertype) {
102         this.securityRuleEthertype = securityRuleEthertype;
103     }
104
105     public String getSecurityRuleRemoteIpPrefix() {
106         return securityRuleRemoteIpPrefix;
107     }
108
109     public void setSecurityRuleRemoteIpPrefix(String securityRuleRemoteIpPrefix) {
110         this.securityRuleRemoteIpPrefix = securityRuleRemoteIpPrefix;
111     }
112
113     public String getSecurityRemoteGroupID() {
114         return securityRemoteGroupID;
115     }
116
117     public void setSecurityRemoteGroupID(String securityRemoteGroupID) {
118         this.securityRemoteGroupID = securityRemoteGroupID;
119     }
120
121     public String getSecurityRuleGroupID() {
122         return securityRuleGroupID;
123     }
124
125     public void setSecurityRuleGroupID(String securityRuleGroupID) {
126         this.securityRuleGroupID = securityRuleGroupID;
127     }
128
129     @Override
130     protected boolean extractField(String field, NeutronSecurityRule ans) {
131         switch (field) {
132             case "direction":
133                 ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
134                 break;
135             case "protocol":
136                 ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
137                 break;
138             case "port_range_min":
139                 ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
140                 break;
141             case "port_range_max":
142                 ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
143                 break;
144             case "ethertype":
145                 ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
146                 break;
147             case "remote_ip_prefix":
148                 ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
149                 break;
150             case "remote_group_id":
151                 ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
152                 break;
153             case "security_group_id":
154                 ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
155                 break;
156             default:
157                 return super.extractField(field, ans);
158         }
159         return true;
160     }
161
162     @Override
163     public String toString() {
164         return "NeutronSecurityRule{" + "securityRuleUUID='" + uuid + '\'' + ", securityRuleDirection='"
165                 + securityRuleDirection + '\'' + ", securityRuleProtocol='" + securityRuleProtocol + '\''
166                 + ", securityRulePortMin=" + securityRulePortMin + ", securityRulePortMax=" + securityRulePortMax
167                 + ", securityRuleEthertype='" + securityRuleEthertype + '\'' + ", securityRuleRemoteIpPrefix='"
168                 + securityRuleRemoteIpPrefix + '\'' + ", securityRemoteGroupID=" + securityRemoteGroupID
169                 + ", securityRuleGroupID='" + securityRuleGroupID + '\'' + ", securityRuleTenantID='" + tenantID + '\''
170                 + '}';
171     }
172 }