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