Merge "Bug 6641: Fix ip_address in allowed_address_pairs info"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronSFCFlowClassifier.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. 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 package org.opendaylight.neutron.spi;
9
10 import java.io.Serializable;
11 import java.util.HashMap;
12 import java.util.Iterator;
13 import java.util.List;
14 import java.util.Map;
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlElement;
18 import javax.xml.bind.annotation.XmlRootElement;
19 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
20
21 @XmlRootElement
22 @XmlAccessorType(XmlAccessType.NONE)
23 public final class NeutronSFCFlowClassifier extends NeutronObject<NeutronSFCFlowClassifier>
24         implements Serializable, INeutronObject<NeutronSFCFlowClassifier> {
25     private static final long serialVersionUID = 1L;
26
27     // See OpenStack Networking SFC (networking-sfc) API v1.0 Reference for description of
28     // annotated attributes
29     @XmlElement(name = "name")
30     String name;
31
32     @XmlElement(defaultValue = "IPv4", name = "ethertype")
33     String ethertype;
34
35     @XmlElement(name = "protocol")
36     String protocol;
37
38     @XmlElement(name = "source_port_range_min")
39     Integer sourcePortRangeMin;
40
41     @XmlElement(name = "source_port_range_max")
42     Integer sourcePortRangeMax;
43
44     @XmlElement(name = "destination_port_range_min")
45     Integer destinationPortRangeMin;
46
47     @XmlElement(name = "destination_port_range_max")
48     Integer destinationPortRangeMax;
49
50     @XmlElement(name = "source_ip_prefix")
51     String sourceIpPrefix;
52
53     @XmlElement(name = "destination_ip_prefix")
54     String destinationIpPrefix;
55
56     @XmlElement(name = "logical_source_port")
57     String logicalSourcePortUUID;
58
59     @XmlElement(name = "logical_destination_port")
60     String logicalDestinationPortUUID;
61
62     @XmlElement(name = "l7_parameters")
63     @XmlJavaTypeAdapter(NeutronResourceMapPropertyAdapter.class)
64     Map<String, String> l7Parameters;
65
66     public NeutronSFCFlowClassifier() {
67     }
68
69     public String getName() {
70         return name;
71     }
72
73     public void setName(String name) {
74         this.name = name;
75     }
76
77     public String getEthertype() {
78         return ethertype;
79     }
80
81     public void setEthertype(String ethertype) {
82         this.ethertype = ethertype;
83     }
84
85     public String getProtocol() {
86         return protocol;
87     }
88
89     public void setProtocol(String protocol) {
90         this.protocol = protocol;
91     }
92
93     public Integer getSourcePortRangeMin() {
94         return sourcePortRangeMin;
95     }
96
97     public void setSourcePortRangeMin(Integer sourcePortRangeMin) {
98         this.sourcePortRangeMin = sourcePortRangeMin;
99     }
100
101     public Integer getSourcePortRangeMax() {
102         return sourcePortRangeMax;
103     }
104
105     public void setSourcePortRangeMax(Integer sourcePortRangeMax) {
106         this.sourcePortRangeMax = sourcePortRangeMax;
107     }
108
109     public Integer getDestinationPortRangeMin() {
110         return destinationPortRangeMin;
111     }
112
113     public void setDestinationPortRangeMin(Integer destinationPortRangeMin) {
114         this.destinationPortRangeMin = destinationPortRangeMin;
115     }
116
117     public Integer getDestinationPortRangeMax() {
118         return destinationPortRangeMax;
119     }
120
121     public void setDestinationPortRangeMax(Integer destinationPortRangeMax) {
122         this.destinationPortRangeMax = destinationPortRangeMax;
123     }
124
125     public String getSourceIpPrefix() {
126         return sourceIpPrefix;
127     }
128
129     public void setSourceIpPrefix(String sourceIpPrefix) {
130         this.sourceIpPrefix = sourceIpPrefix;
131     }
132
133     public String getLogicalSourcePortUUID() {
134         return logicalSourcePortUUID;
135     }
136
137     public void setLogicalSourcePortUUID(String logicalSourcePortUUID) {
138         this.logicalSourcePortUUID = logicalSourcePortUUID;
139     }
140
141     public String getDestinationIpPrefix() {
142         return destinationIpPrefix;
143     }
144
145     public void setDestinationIpPrefix(String destinationIpPrefix) {
146         this.destinationIpPrefix = destinationIpPrefix;
147     }
148
149     public String getLogicalDestinationPortUUID() {
150         return logicalDestinationPortUUID;
151     }
152
153     public void setLogicalDestinationPortUUID(String logicalDestinationPortUUID) {
154         this.logicalDestinationPortUUID = logicalDestinationPortUUID;
155     }
156
157     public Map<String, String> getL7Parameters() {
158         return l7Parameters;
159     }
160
161     public void setL7Parameters(Map<String, String> l7Parameters) {
162         this.l7Parameters = l7Parameters;
163     }
164
165     /**
166      * This method copies selected fields from the object and returns them
167      * as a new object, suitable for marshaling.
168      *
169      * @param fields List of attributes to be extracted
170      * @return an OpenStack NeutronSFCFlowClassifier object with only the selected fields
171      * populated
172      */
173
174     public NeutronSFCFlowClassifier extractFields(List<String> fields) {
175         NeutronSFCFlowClassifier ans = new NeutronSFCFlowClassifier();
176         Iterator<String> i = fields.iterator();
177         while (i.hasNext()) {
178             String s = i.next();
179             if (s.equals("id")) {
180                 ans.setID(this.getID());
181             }
182             if (s.equals("tenant_id")) {
183                 ans.setTenantID(this.getTenantID());
184             }
185             if (s.equals("name")) {
186                 ans.setName(this.getName());
187             }
188             if (s.equals("ethertype")) {
189                 ans.setEthertype(this.getEthertype());
190             }
191             if (s.equals("source_port_range_min")) {
192                 ans.setSourcePortRangeMin(this.getSourcePortRangeMin());
193             }
194             if (s.equals("source_port_range_max")) {
195                 ans.setSourcePortRangeMax(this.getSourcePortRangeMax());
196             }
197             if (s.equals("destination_port_range_min")) {
198                 ans.setDestinationPortRangeMin(this.getDestinationPortRangeMin());
199             }
200             if (s.equals("destination_port_range_max")) {
201                 ans.setDestinationPortRangeMax(this.getDestinationPortRangeMax());
202             }
203             if (s.equals("source_ip_prefix")) {
204                 ans.setSourceIpPrefix(this.getSourceIpPrefix());
205             }
206             if (s.equals("destination_ip_prefix")) {
207                 ans.setDestinationIpPrefix(this.getDestinationIpPrefix());
208             }
209             if (s.equals("logical_source_port")) {
210                 ans.setLogicalDestinationPortUUID(this.getLogicalDestinationPortUUID());
211             }
212             if (s.equals("logical_destination_port")) {
213                 ans.setLogicalDestinationPortUUID(this.getLogicalDestinationPortUUID());
214             }
215             if (s.equals("l7_parameters")) {
216                 ans.setL7Parameters(new HashMap<String, String>(this.getL7Parameters()));
217             }
218         }
219         return ans;
220     }
221
222     @Override
223     public String toString() {
224         return "NeutronSFCFlowClassifier[" + "name='" + name + '\'' + ", ethertype='" + ethertype + '\''
225                 + ", protocol='" + protocol + '\'' + ", sourcePortRangeMin=" + sourcePortRangeMin
226                 + ", sourcePortRangeMax=" + sourcePortRangeMax + ", destinationPortRangeMin=" + destinationPortRangeMin
227                 + ", destinationPortRangeMax=" + destinationPortRangeMax + ", sourceIpPrefix='" + sourceIpPrefix + '\''
228                 + ", destinationIpPrefix='" + destinationIpPrefix + '\'' + ", logicalSourcePortUUID='"
229                 + logicalSourcePortUUID + '\'' + ", logicalDestinationPortUUID='" + logicalDestinationPortUUID + '\''
230                 + ", l7Parameters=" + l7Parameters + ']';
231     }
232 }