1453a1bf7186ecb7e5e345e2908c6eebb7589bb1
[music.git] / jar / 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     public ReturnType(ResultType result, String message) {
32         super();
33         this.result = result;
34         this.message = message;
35     }
36
37     public String getTimingInfo() {
38         return timingInfo;
39     }
40
41     public void setTimingInfo(String timingInfo) {
42         this.timingInfo = timingInfo;
43     }
44
45     private String timingInfo;
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 }