Merge "Read lock promotion"
[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
23 package org.onap.music.main;
24
25 import java.util.HashMap;
26 import java.util.Map;
27
28 public class ReturnType {
29     private ResultType result;
30     private String message;
31
32     private String timingInfo;
33
34     public ReturnType(ResultType result, String message) {
35         super();
36         this.result = result;
37         this.message = message;
38     }
39
40     public String getTimingInfo() {
41         return timingInfo;
42     }
43
44     public void setTimingInfo(String timingInfo) {
45         this.timingInfo = timingInfo;
46     }
47
48     public ResultType getResult() {
49         return result;
50     }
51
52     public String getMessage() {
53         return message;
54     }
55
56     public void setMessage(String message) {
57         this.message = message;
58     }
59
60     public String toJson() {
61         return "{ \"result\":\"" + result.getResult() + "\", \"message\":\"" + message + "\"}";
62     }
63
64     public String toString() {
65         return result + " | " + message;
66     }
67
68     public Map<String, Object> toMap() {
69         Map<String, Object> newMap = new HashMap<>();
70         newMap.put("result", result.getResult());
71         newMap.put("message", message);
72         return newMap;
73     }
74
75 }