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