Merge "Reorder modifiers"
[so.git] / adapters / mso-adapters-rest-interface / src / main / java / org / openecomp / mso / adapters / sdncrest / SDNCServiceResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.openecomp.mso.adapters.sdncrest;
21
22 import java.io.Serializable;
23 import java.util.LinkedHashMap;
24 import java.util.Map;
25
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlRootElement;
28
29 import com.fasterxml.jackson.annotation.JsonInclude;
30 import com.fasterxml.jackson.annotation.JsonInclude.Include;
31 import com.fasterxml.jackson.annotation.JsonProperty;
32 import com.fasterxml.jackson.annotation.JsonRootName;
33
34 // NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy,
35 //       even though we are using JSON exclusively.  The @NoJackson annotation
36 //       is also required in this environment.
37
38 /**
39  Map<String, String> elements when marshalled to XML produce a list of <entry><key>${key}</key><value>${value}</value></entry> elements.
40  When marshalling to JSON they create a list of "${key}" : "${value}" pairs with no extra wrappers.
41  * </pre>
42  */
43 @JsonRootName("SDNCServiceResponse")
44 @JsonInclude(Include.NON_NULL)
45 @XmlRootElement(name = "SDNCServiceResponse")
46 public class SDNCServiceResponse extends SDNCResponseCommon implements Serializable {
47         private static final long serialVersionUID = 1L;
48
49         // Map of response parameters (possibly none).
50         private Map<String, String> params = null;
51
52         public SDNCServiceResponse(String sdncRequestId, String responseCode,
53                         String responseMessage, String ackFinalIndicator) {
54                 super(sdncRequestId, responseCode, responseMessage, ackFinalIndicator);
55         }
56
57         public SDNCServiceResponse() {
58         }
59
60         @JsonProperty("params")
61         @XmlElement(name = "params")
62         public Map<String, String> getParams() {
63                 return params;
64         }
65
66         @JsonProperty("params")
67         public void setParams(Map<String, String> params) {
68                 this.params = params;
69         }
70
71         public void addParam(String name, String value) {
72                 if (params == null) {
73                         params = new LinkedHashMap<>();
74                 }
75                 params.put(name, value);
76         }
77 }