Merge "Fix sonar issue: multiple if statements"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronVpnIkePolicy.java
1 /*
2  * Copyright (c) 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.List;
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 org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 @XmlRootElement
21 @XmlAccessorType(XmlAccessType.NONE)
22 public final class NeutronVpnIkePolicy extends NeutronBaseAttributes<NeutronVpnIkePolicy> implements Serializable {
23     private static final Logger LOGGER = LoggerFactory.getLogger(NeutronVpnIkePolicy.class);
24     private static final long serialVersionUID = 1L;
25
26     // See OpenStack Network API v2.0 Reference for description of
27     // annotated attributes
28
29     @XmlElement(name = "auth_algorithm")
30     String authAlgorithm;
31
32     @XmlElement(name = "encryption_algorithm")
33     String encryptionAlgorithm;
34
35     @XmlElement(name = "phase1_negotiation_mode")
36     String phase1NegotiationMode;
37
38     @XmlElement(name = "pfs")
39     String perfectForwardSecrecy;
40
41     @XmlElement(name = "ike_version")
42     String ikeVersion;
43
44     @XmlElement(name = "lifetime")
45     NeutronVpnLifetime lifetime;
46
47     public NeutronVpnIkePolicy() {
48     }
49
50     public String getAuthAlgorithm() {
51         return authAlgorithm;
52     }
53
54     public void setAuthAlgorithm(String authAlgorithm) {
55         this.authAlgorithm = authAlgorithm;
56     }
57
58     public String getEncryptionAlgorithm() {
59         return encryptionAlgorithm;
60     }
61
62     public void setEncryptionAlgorithm(String encryptionAlgorithm) {
63         this.encryptionAlgorithm = encryptionAlgorithm;
64     }
65
66     public String getPhase1NegotiationMode() {
67         return phase1NegotiationMode;
68     }
69
70     public void setPhase1NegotiationMode(String phase1NegotiationMode) {
71         this.phase1NegotiationMode = phase1NegotiationMode;
72     }
73
74     public String getPerfectForwardSecrecy() {
75         return perfectForwardSecrecy;
76     }
77
78     public void setPerfectForwardSecrecy(String perfectForwardSecrecy) {
79         this.perfectForwardSecrecy = perfectForwardSecrecy;
80     }
81
82     public String getIkeVersion() {
83         return ikeVersion;
84     }
85
86     public void setIkeVersion(String ikeVersion) {
87         this.ikeVersion = ikeVersion;
88     }
89
90     public NeutronVpnLifetime getLifetime() {
91         return lifetime;
92     }
93
94     public void setLifetime(NeutronVpnLifetime lifetime) {
95         this.lifetime = lifetime;
96     }
97
98     /**
99      * This method copies selected fields from the object and returns them
100      * as a new object, suitable for marshaling.
101      *
102      * @param fields
103      *            List of attributes to be extracted
104      * @return a NeutronVpnIkePolicy object with only the selected fields
105      *             populated
106      */
107     public NeutronVpnIkePolicy extractFields(List<String> fields) {
108         NeutronVpnIkePolicy ans = new NeutronVpnIkePolicy();
109         for (String s : fields) {
110             if (extractField(s, ans)) {
111                 continue;
112             }
113             switch (s) {
114                 case "auth_algorithm":
115                     ans.setAuthAlgorithm(this.getAuthAlgorithm());
116                     break;
117                 case "encryption_algorithm":
118                     ans.setEncryptionAlgorithm(this.getEncryptionAlgorithm());
119                     break;
120                 case "phase1_negotiation_mode":
121                     ans.setPhase1NegotiationMode(this.getPhase1NegotiationMode());
122                     break;
123                 case "pfs":
124                     ans.setPerfectForwardSecrecy(this.getPerfectForwardSecrecy());
125                     break;
126                 case "ike_version":
127                     ans.setIkeVersion(this.getIkeVersion());
128                     break;
129                 default:
130                     LOGGER.warn("{} is not an NeutronVpnIkePolicy suitable field.", s);
131                     break;
132             }
133         }
134         return ans;
135     }
136 }