Fix FindBugs violations
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronBgpvpn.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. 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.util.List;
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlElement;
15 import javax.xml.bind.annotation.XmlRootElement;
16
17 @XmlRootElement(name = "bgpvpn")
18 @XmlAccessorType(XmlAccessType.NONE)
19 public final class NeutronBgpvpn extends NeutronAdminAttributes<NeutronBgpvpn> {
20     // See OpenStack Network API v2.0 Reference for description of
21     // annotated attributes
22
23     private static final long serialVersionUID = 1L;
24
25     @XmlElement(defaultValue = "l3", name = "type")
26     String type;
27
28     @XmlElement(name = "technique")
29     String technique;
30
31     @XmlElement(name = "route_targets")
32     List<String> routeTargets;
33
34     @XmlElement(name = "import_targets")
35     List<String> importTargets;
36
37     @XmlElement(name = "export_targets")
38     List<String> exportTargets;
39
40     @XmlElement(name = "route_distinguishers")
41     List<String> routeDistinguishers;
42
43     @XmlElement(name = "vnid")
44     Long vnid;
45
46     @XmlElement(defaultValue = "false", name = "auto_aggregate")
47     Boolean autoAggregate;
48
49     @XmlElement(name = "networks")
50     List<String> networks;
51
52     @XmlElement(name = "routers")
53     List<String> routers;
54
55     /* This attribute lists the ports associated with an instance
56      * which is needed for determining if that instance can be deleted
57      */
58
59     public NeutronBgpvpn() {
60     }
61
62     @Override
63     public void initDefaults() {
64         super.initDefaults();
65         if (type == null) {
66             type = "l3";
67         }
68         if (autoAggregate == null) {
69             autoAggregate = false;
70         }
71     }
72
73     public boolean isAutoAggregate() {
74         return autoAggregate;
75     }
76
77     public String getType() {
78         return type;
79     }
80
81     public void setType(String type) {
82         this.type = type;
83     }
84
85     public String getTechnique() {
86         return technique;
87     }
88
89     public void setTechnique(String technique) {
90         this.technique = technique;
91     }
92
93     public List<String> getRouteTargets() {
94         return routeTargets;
95     }
96
97     public void setRouteTargets(List<String> routeTargets) {
98         this.routeTargets = routeTargets;
99     }
100
101     public void addRouteTarget(String uuid) {
102         routeTargets.add(uuid);
103     }
104
105     public void removeRouteTarget(String uuid) {
106         routeTargets.remove(uuid);
107     }
108
109     public List<String> getImportTargets() {
110         return importTargets;
111     }
112
113     public void setImportTargets(List<String> importTargets) {
114         this.importTargets = importTargets;
115     }
116
117     public void addImportTarget(String uuid) {
118         importTargets.add(uuid);
119     }
120
121     public void removeImportTarget(String uuid) {
122         importTargets.remove(uuid);
123     }
124
125     public List<String> getExportTargets() {
126         return exportTargets;
127     }
128
129     public void setExportTargets(List<String> exportTargets) {
130         this.exportTargets = exportTargets;
131     }
132
133     public void addExportTarget(String uuid) {
134         exportTargets.add(uuid);
135     }
136
137     public void removeExportTarget(String uuid) {
138         exportTargets.remove(uuid);
139     }
140
141     public List<String> getRouteDistinguishers() {
142         return routeDistinguishers;
143     }
144
145     public void setRouteDistinguishers(List<String> routeDistinguishers) {
146         this.routeDistinguishers = routeDistinguishers;
147     }
148
149     public void addRouteDistinguisher(String uuid) {
150         routeDistinguishers.add(uuid);
151     }
152
153     public void removeRouteDistinguisher(String uuid) {
154         routeDistinguishers.remove(uuid);
155     }
156
157     public Long getVnid() {
158         return vnid;
159     }
160
161     public void setVnid(Long input) {
162         vnid = input;
163     }
164
165     public Boolean getAutoAggregate() {
166         return autoAggregate;
167     }
168
169     public void setAutoAggregate(boolean newValue) {
170         autoAggregate = newValue;
171     }
172
173     public List<String> getNetworks() {
174         return networks;
175     }
176
177     public void setNetworks(List<String> networks) {
178         this.networks = networks;
179     }
180
181     public void addNetwork(String uuid) {
182         networks.add(uuid);
183     }
184
185     public void removeNetwork(String uuid) {
186         networks.remove(uuid);
187     }
188
189     public List<String> getRouters() {
190         return routers;
191     }
192
193     public void setRouters(List<String> routers) {
194         this.routers = routers;
195     }
196
197     public void addRouter(String uuid) {
198         routers.add(uuid);
199     }
200
201     public void removeRouter(String uuid) {
202         routers.remove(uuid);
203     }
204
205     @Override
206     protected boolean extractField(String field, NeutronBgpvpn ans) {
207         switch (field) {
208             case "type":
209                 ans.setType(this.getType());
210                 break;
211             case "technique":
212                 ans.setTechnique(this.getTechnique());
213                 break;
214             case "route_targets":
215                 ans.setRouteTargets(this.getRouteTargets());
216                 break;
217             case "import_targets":
218                 ans.setImportTargets(this.getImportTargets());
219                 break;
220             case "export_targets":
221                 ans.setExportTargets(this.getExportTargets());
222                 break;
223             case "route_distinguishe":
224                 ans.setRouteDistinguishers(this.getRouteDistinguishers());
225                 break;
226             case "routers":
227                 ans.setRouters(this.getRouters());
228                 break;
229             case "networks":
230                 ans.setNetworks(this.getNetworks());
231                 break;
232             case "vnid":
233                 ans.setVnid(this.getVnid());
234                 break;
235             case "auto_aggregate":
236                 ans.setAutoAggregate(this.getAutoAggregate());
237                 break;
238             default:
239                 return super.extractField(field, ans);
240         }
241         return true;
242     }
243
244     @Override
245     public String toString() {
246         return "NeutronBgpvpn [bgpvpnUUID=" + uuid + ", bgpvpnName=" + name + ", adminStateUp=" + adminStateUp
247                 + ", status=" + status + ", tenantID=" + tenantID + ", type=" + type + ", technique=" + technique
248                 + ", routeTargets=" + routeTargets + ", importTargets=" + importTargets + ", exportTargets="
249                 + exportTargets + ", routeDistinguishers=" + routeDistinguishers + ", vnid = " + vnid
250                 + ", autoAggregate = " + autoAggregate + ", networks = " + networks + ", routers = " + routers + "]";
251     }
252 }