da291dcbab148e8a0f9540fb4e0436884c07bbc8
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronSFCPortPair.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 NeutronSFCPortPair extends NeutronBaseAttributes<NeutronSFCPortPair> implements Serializable {
22     private static final long serialVersionUID = 1L;
23
24     // See OpenStack Networking SFC (networking-sfc) Port Pair API v1.0 Reference
25     // for description of annotated attributes
26     @XmlElement(name = "ingress")
27     String ingressPortUUID;
28
29     @XmlElement(name = "egress")
30     String egressPortUUID;
31
32     @XmlElement(name = "service_function_parameters")
33     @XmlJavaTypeAdapter(NeutronResourceMapPropertyAdapter.class)
34     Map<String, String> serviceFunctionParameters;
35
36     public NeutronSFCPortPair() {
37     }
38
39     public String getIngressPortUUID() {
40         return ingressPortUUID;
41     }
42
43     public void setIngressPortUUID(String ingressPortUUID) {
44         this.ingressPortUUID = ingressPortUUID;
45     }
46
47     public String getEgressPortUUID() {
48         return egressPortUUID;
49     }
50
51     public void setEgressPortUUID(String egressPortUUID) {
52         this.egressPortUUID = egressPortUUID;
53     }
54
55     public Map<String, String> getServiceFunctionParameters() {
56         return serviceFunctionParameters;
57     }
58
59     public void setServiceFunctionParameters(Map<String, String> serviceFunctionParameters) {
60         this.serviceFunctionParameters = serviceFunctionParameters;
61     }
62
63     @Override
64     protected boolean extractField(String field, NeutronSFCPortPair ans) {
65         switch (field) {
66             case "ingress":
67                 ans.setIngressPortUUID(this.getIngressPortUUID());
68                 break;
69             case "egress":
70                 ans.setEgressPortUUID(this.getEgressPortUUID());
71                 break;
72             case "service_function_parameters":
73                 ans.setServiceFunctionParameters(new HashMap<>(this.getServiceFunctionParameters()));
74                 break;
75             default:
76                 return super.extractField(field, ans);
77         }
78         return true;
79     }
80
81     @Override
82     public String toString() {
83         return "NeutronSFCPortPair[" + "tenantID='" + tenantID + '\'' + ", name='" + name + '\'' + ", ingressPortUUID='"
84                 + ingressPortUUID + '\'' + ", egressPortUUID='" + egressPortUUID + '\'' + ", serviceFunctionParameters="
85                 + serviceFunctionParameters + ']';
86     }
87 }