sort out signature of extraceField method
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronRouter.java
1 /*
2  * Copyright (c) 2013, 2015 IBM Corporation 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.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 @XmlRootElement
20 @XmlAccessorType(XmlAccessType.NONE)
21 public class NeutronRouter extends NeutronObject<NeutronRouter>
22         implements Serializable, INeutronObject<NeutronRouter> {
23     private static final long serialVersionUID = 1L;
24
25     // See OpenStack Network API v2.0 Reference for description of
26     // annotated attributes
27     @XmlElement(name = "name")
28     String name;
29
30     @XmlElement(defaultValue = "true", name = "admin_state_up")
31     Boolean adminStateUp;
32
33     @XmlElement(name = "status")
34     String status;
35
36     @XmlElement(name = "external_gateway_info", nillable = true)
37     NeutronRouter_NetworkReference externalGatewayInfo;
38
39     @XmlElement(name = "distributed")
40     Boolean distributed;
41
42     @XmlElement(name = "gw_port_id", nillable = true)
43     String gatewayPortId;
44
45     @XmlElement(name = "routes")
46     List<NeutronRoute> routes;
47
48     public NeutronRouter() {
49     }
50
51     public String getName() {
52         return name;
53     }
54
55     public void setName(String name) {
56         this.name = name;
57     }
58
59     public boolean isAdminStateUp() {
60         if (adminStateUp == null) {
61             return true;
62         }
63         return adminStateUp;
64     }
65
66     public Boolean getAdminStateUp() {
67         return adminStateUp;
68     }
69
70     public void setAdminStateUp(Boolean newValue) {
71         adminStateUp = newValue;
72     }
73
74     public String getStatus() {
75         return status;
76     }
77
78     public void setStatus(String status) {
79         this.status = status;
80     }
81
82     public NeutronRouter_NetworkReference getExternalGatewayInfo() {
83         return externalGatewayInfo;
84     }
85
86     public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
87         this.externalGatewayInfo = externalGatewayInfo;
88     }
89
90     public Boolean getDistributed() {
91         return distributed;
92     }
93
94     public void setDistributed(Boolean distributed) {
95         this.distributed = distributed;
96     }
97
98     public String getGatewayPortId() {
99         return gatewayPortId;
100     }
101
102     public void setGatewayPortId(String gatewayPortId) {
103         this.gatewayPortId = gatewayPortId;
104     }
105
106     public List<NeutronRoute> getRoutes() {
107         return routes;
108     }
109
110     public void setRoutes(List<NeutronRoute> routes) {
111         this.routes = routes;
112     }
113
114     /**
115      * This method copies selected fields from the object and returns them
116      * as a new object, suitable for marshaling.
117      *
118      * @param fields
119      *            List of attributes to be extracted
120      * @return an OpenStackRouters object with only the selected fields
121      * populated
122      */
123     public NeutronRouter extractFields(List<String> fields) {
124         NeutronRouter ans = new NeutronRouter();
125         Iterator<String> i = fields.iterator();
126         while (i.hasNext()) {
127             String s = i.next();
128             if (s.equals("id")) {
129                 ans.setID(this.getID());
130             }
131             if (s.equals("name")) {
132                 ans.setName(this.getName());
133             }
134             if (s.equals("admin_state_up")) {
135                 ans.setAdminStateUp(this.getAdminStateUp());
136             }
137             if (s.equals("status")) {
138                 ans.setStatus(this.getStatus());
139             }
140             if (s.equals("tenant_id")) {
141                 ans.setTenantID(this.getTenantID());
142             }
143             if (s.equals("external_gateway_info")) {
144                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
145             }
146             if (s.equals("distributed")) {
147                 ans.setDistributed(this.getDistributed());
148             }
149             if (s.equals("gw_port_id")) {
150                 ans.setGatewayPortId(this.getGatewayPortId());
151             }
152             if (s.equals("routes")) {
153                 ans.setRoutes(this.getRoutes());
154             }
155         }
156         return ans;
157     }
158
159     @Override
160     public void initDefaults() {
161         adminStateUp = true;
162     }
163
164     @Override
165     public String toString() {
166         return "NeutronRouter [" + "id=" + uuid + ", name=" + name + ", adminStateUp=" + adminStateUp + ", status="
167                 + status + ", tenantID=" + tenantID + ", external_gateway_info=" + externalGatewayInfo
168                 + ", distributed=" + distributed + ", gw_port_id=" + gatewayPortId + ", routes=" + routes + "]";
169     }
170
171 }