checkstyle: TypeName
[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.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
19 @XmlAccessorType(XmlAccessType.NONE)
20 public final class NeutronRouter extends NeutronAdminAttributes<NeutronRouter>
21         implements Serializable {
22     private static final long serialVersionUID = 1L;
23
24     // See OpenStack Network API v2.0 Reference for description of
25     // annotated attributes
26     @XmlElement(name = "external_gateway_info", nillable = true)
27     NeutronRouterNetworkReference externalGatewayInfo;
28
29     @XmlElement(name = "distributed")
30     Boolean distributed;
31
32     @XmlElement(name = "gw_port_id", nillable = true)
33     String gatewayPortId;
34
35     @XmlElement(name = "routes")
36     List<NeutronRoute> routes;
37
38     public NeutronRouter() {
39     }
40
41     public boolean isAdminStateUp() {
42         if (adminStateUp == null) {
43             return true;
44         }
45         return adminStateUp;
46     }
47
48     public NeutronRouterNetworkReference getExternalGatewayInfo() {
49         return externalGatewayInfo;
50     }
51
52     public void setExternalGatewayInfo(NeutronRouterNetworkReference externalGatewayInfo) {
53         this.externalGatewayInfo = externalGatewayInfo;
54     }
55
56     public Boolean getDistributed() {
57         return distributed;
58     }
59
60     public void setDistributed(Boolean distributed) {
61         this.distributed = distributed;
62     }
63
64     public String getGatewayPortId() {
65         return gatewayPortId;
66     }
67
68     public void setGatewayPortId(String gatewayPortId) {
69         this.gatewayPortId = gatewayPortId;
70     }
71
72     public List<NeutronRoute> getRoutes() {
73         return routes;
74     }
75
76     public void setRoutes(List<NeutronRoute> routes) {
77         this.routes = routes;
78     }
79
80     /**
81      * This method copies selected fields from the object and returns them
82      * as a new object, suitable for marshaling.
83      *
84      * @param fields
85      *            List of attributes to be extracted
86      * @return an OpenStackRouters object with only the selected fields
87      *             populated
88      */
89     public NeutronRouter extractFields(List<String> fields) {
90         NeutronRouter ans = new NeutronRouter();
91         for (String s : fields) {
92             extractField(s, ans);
93             if (s.equals("external_gateway_info")) {
94                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
95             }
96             if (s.equals("distributed")) {
97                 ans.setDistributed(this.getDistributed());
98             }
99             if (s.equals("gw_port_id")) {
100                 ans.setGatewayPortId(this.getGatewayPortId());
101             }
102             if (s.equals("routes")) {
103                 ans.setRoutes(this.getRoutes());
104             }
105         }
106         return ans;
107     }
108
109     @Override
110     public void initDefaults() {
111         adminStateUp = true;
112     }
113
114     @Override
115     public String toString() {
116         return "NeutronRouter [" + "id=" + uuid + ", name=" + name + ", adminStateUp=" + adminStateUp + ", status="
117                 + status + ", tenantID=" + tenantID + ", external_gateway_info=" + externalGatewayInfo
118                 + ", distributed=" + distributed + ", gw_port_id=" + gatewayPortId + ", routes=" + routes + "]";
119     }
120
121 }