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