Merge "Bug 6641: Fix ip_address in allowed_address_pairs info"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronFloatingIP.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 final class NeutronFloatingIP
22         extends NeutronObject<NeutronFloatingIP> implements Serializable, INeutronObject<NeutronFloatingIP> {
23     private static final long serialVersionUID = 1L;
24
25     // See OpenStack Network API v2.0 Reference for description of
26     // annotated attributes
27
28     @XmlElement(name = "floating_network_id")
29     String floatingNetworkUUID;
30
31     @XmlElement(name = "port_id")
32     String portUUID;
33
34     @XmlElement(name = "fixed_ip_address")
35     String fixedIPAddress;
36
37     @XmlElement(name = "floating_ip_address")
38     String floatingIPAddress;
39
40     @XmlElement(name = "router_id")
41     String routerUUID;
42
43     @XmlElement(name = "status")
44     String status;
45
46     public NeutronFloatingIP() {
47     }
48
49     public String getFloatingNetworkUUID() {
50         return floatingNetworkUUID;
51     }
52
53     public void setFloatingNetworkUUID(String floatingNetworkUUID) {
54         this.floatingNetworkUUID = floatingNetworkUUID;
55     }
56
57     public String getPortUUID() {
58         return portUUID;
59     }
60
61     public String getRouterUUID() {
62         return routerUUID;
63     }
64
65     public void setPortUUID(String portUUID) {
66         this.portUUID = portUUID;
67     }
68
69     public String getFixedIPAddress() {
70         return fixedIPAddress;
71     }
72
73     public void setFixedIPAddress(String fixedIPAddress) {
74         this.fixedIPAddress = fixedIPAddress;
75     }
76
77     public String getFloatingIPAddress() {
78         return floatingIPAddress;
79     }
80
81     public void setFloatingIPAddress(String floatingIPAddress) {
82         this.floatingIPAddress = floatingIPAddress;
83     }
84
85     public void setRouterUUID(String routerUUID) {
86         this.routerUUID = routerUUID;
87     }
88
89     public String getStatus() {
90         return status;
91     }
92
93     public void setStatus(String status) {
94         this.status = status;
95     }
96
97     /**
98      * This method copies selected fields from the object and returns them
99      * as a new object, suitable for marshaling.
100      *
101      * @param fields
102      *            List of attributes to be extracted
103      * @return an OpenStackFloatingIPs object with only the selected fields
104      * populated
105      */
106
107     public NeutronFloatingIP extractFields(List<String> fields) {
108         NeutronFloatingIP ans = new NeutronFloatingIP();
109         Iterator<String> i = fields.iterator();
110         while (i.hasNext()) {
111             String s = i.next();
112             if (s.equals("id")) {
113                 ans.setID(this.getID());
114             }
115             if (s.equals("floating_network_id")) {
116                 ans.setFloatingNetworkUUID(this.getFloatingNetworkUUID());
117             }
118             if (s.equals("port_id")) {
119                 ans.setPortUUID(this.getPortUUID());
120             }
121             if (s.equals("fixed_ip_address")) {
122                 ans.setFixedIPAddress(this.getFixedIPAddress());
123             }
124             if (s.equals("floating_ip_address")) {
125                 ans.setFloatingIPAddress(this.getFloatingIPAddress());
126             }
127             if (s.equals("tenant_id")) {
128                 ans.setTenantID(this.getTenantID());
129             }
130             if (s.equals("router_id")) {
131                 ans.setRouterUUID(this.getRouterUUID());
132             }
133             if (s.equals("status")) {
134                 ans.setStatus(this.getStatus());
135             }
136         }
137         return ans;
138     }
139
140     @Override
141     public String toString() {
142         return "NeutronFloatingIP{" + "fipUUID='" + uuid + '\'' + ", fipFloatingNetworkId='" + floatingNetworkUUID
143                 + '\'' + ", fipPortUUID='" + portUUID + '\'' + ", fipFixedIPAddress='" + fixedIPAddress + '\''
144                 + ", fipFloatingIPAddress=" + floatingIPAddress + ", fipTenantId='" + tenantID + '\''
145                 + ", fipRouterId='" + routerUUID + '\'' + ", fipStatus='" + status + '\'' + '}';
146     }
147 }