clean up: remove unused import
[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
22 public class NeutronRouter extends NeutronObject implements Serializable, INeutronObject {
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() { return adminStateUp; }
67
68     public void setAdminStateUp(Boolean newValue) {
69         adminStateUp = newValue;
70     }
71
72     public String getStatus() {
73         return status;
74     }
75
76     public void setStatus(String status) {
77         this.status = status;
78     }
79
80     public NeutronRouter_NetworkReference getExternalGatewayInfo() {
81         return externalGatewayInfo;
82     }
83
84     public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
85         this.externalGatewayInfo = externalGatewayInfo;
86     }
87
88     public Boolean getDistributed() {
89         return distributed;
90     }
91
92     public void setDistributed(Boolean distributed) {
93         this.distributed = distributed;
94     }
95
96     public String getGatewayPortId() {
97         return gatewayPortId;
98     }
99
100     public void setGatewayPortId(String gatewayPortId) {
101         this.gatewayPortId = gatewayPortId;
102     }
103
104     public List<NeutronRoute> getRoutes() {
105         return routes;
106     }
107
108     public void setRoutes(List<NeutronRoute> routes) {
109         this.routes = routes;
110     }
111
112     /**
113      * This method copies selected fields from the object and returns them
114      * as a new object, suitable for marshaling.
115      *
116      * @param fields
117      *            List of attributes to be extracted
118      * @return an OpenStackRouters object with only the selected fields
119      * populated
120      */
121     public NeutronRouter extractFields(List<String> fields) {
122         NeutronRouter ans = new NeutronRouter();
123         Iterator<String> i = fields.iterator();
124         while (i.hasNext()) {
125             String s = i.next();
126             if (s.equals("id")) {
127                 ans.setID(this.getID());
128             }
129             if (s.equals("name")) {
130                 ans.setName(this.getName());
131             }
132             if (s.equals("admin_state_up")) {
133                 ans.setAdminStateUp(this.getAdminStateUp());
134             }
135             if (s.equals("status")) {
136                 ans.setStatus(this.getStatus());
137             }
138             if (s.equals("tenant_id")) {
139                 ans.setTenantID(this.getTenantID());
140             }
141             if (s.equals("external_gateway_info")) {
142                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
143             }
144             if (s.equals("distributed")) {
145                 ans.setDistributed(this.getDistributed());
146             }
147             if (s.equals("gw_port_id")) {
148                 ans.setGatewayPortId(this.getGatewayPortId());
149             }
150             if (s.equals("routes")){
151                 ans.setRoutes(this.getRoutes());
152             }
153         }
154         return ans;
155     }
156
157     @Override
158     public void initDefaults() {
159         adminStateUp = true;
160     }
161
162     @Override
163     public String toString() {
164         return "NeutronRouter [" +
165             "id=" + uuid +
166             ", name=" + name +
167             ", adminStateUp=" + adminStateUp +
168             ", status=" + status +
169             ", tenantID=" + tenantID +
170             ", external_gateway_info=" + externalGatewayInfo +
171             ", distributed=" + distributed +
172             ", gw_port_id=" + gatewayPortId +
173             ", routes=" + routes +
174             "]";
175     }
176
177 }