Merge "Sonar Fix: JsonResponse.java"
[music.git] / src / main / java / org / onap / music / main / ReturnType.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  *  Copyright (c) 2017 AT&T Intellectual Property
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  * 
19  * ============LICENSE_END=============================================
20  * ====================================================================
21  */
22 package org.onap.music.main;
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 public class ReturnType {
28     private ResultType result;
29     private String message;
30
31     private String timingInfo;
32
33     public ReturnType(ResultType result, String message) {
34         super();
35         this.result = result;
36         this.message = message;
37     }
38
39     public String getTimingInfo() {
40         return timingInfo;
41     }
42
43     public void setTimingInfo(String timingInfo) {
44         this.timingInfo = timingInfo;
45     }
46
47     public ResultType getResult() {
48         return result;
49     }
50
51     public String getMessage() {
52         return message;
53     }
54
55     public void setMessage(String message) {
56         this.message = message;
57     }
58
59     public String toJson() {
60         return "{ \"result\":\"" + result.getResult() + "\", \"message\":\"" + message + "\"}";
61     }
62
63     public String toString() {
64         return result + " | " + message;
65     }
66
67     public Map<String, Object> toMap() {
68         Map<String, Object> newMap = new HashMap<>();
69         newMap.put("result", result.getResult());
70         newMap.put("message", message);
71         return newMap;
72     }
73
74 }