e9a1e328fcc9b3b33ad10219d5909e80c9d5d053
[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     @Override
81     protected boolean extractField(String field, NeutronRouter ans) {
82         switch (field) {
83             case "external_gateway_info":
84                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
85                 break;
86             case "distributed":
87                 ans.setDistributed(this.getDistributed());
88                 break;
89             case "gw_port_id":
90                 ans.setGatewayPortId(this.getGatewayPortId());
91                 break;
92             case "routes":
93                 ans.setRoutes(this.getRoutes());
94                 break;
95             default:
96                 return super.extractField(field, ans);
97         }
98         return true;
99     }
100
101     @Override
102     public String toString() {
103         return "NeutronRouter [" + "id=" + uuid + ", name=" + name + ", adminStateUp=" + adminStateUp + ", status="
104                 + status + ", tenantID=" + tenantID + ", external_gateway_info=" + externalGatewayInfo
105                 + ", distributed=" + distributed + ", gw_port_id=" + gatewayPortId + ", routes=" + routes + "]";
106     }
107
108 }