[POLICY-22] Reorganizing drools-apps
[policy/drools-applications.git] / controlloop / common / model-impl / appc / src / main / java / org / onap / policy / appc / Response.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appc
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
21 package org.onap.policy.appc;
22
23 import java.io.Serializable;
24 import java.util.HashMap;
25 import java.util.Map;
26
27 public class Response implements Serializable {
28
29         private static final long serialVersionUID = 434953706339865151L;
30
31         public CommonHeader CommonHeader;
32         public ResponseStatus Status = new ResponseStatus();
33         public Map<String, Object> Payload = new HashMap<String, Object>();
34         
35         public Response() {
36                 
37         }
38         
39         public Response(Request request) {
40                 this.CommonHeader = new CommonHeader(request.CommonHeader);
41                 if (request.Payload != null) {
42                         this.Payload.putAll(request.Payload);
43                 }
44         }
45
46         public CommonHeader getCommonHeader() {
47                 return CommonHeader;
48         }
49
50         public void setCommonHeader(CommonHeader commonHeader) {
51                 CommonHeader = commonHeader;
52         }
53
54         public ResponseStatus getStatus() {
55                 return Status;
56         }
57
58         public void setStatus(ResponseStatus status) {
59                 Status = status;
60         }
61
62         public Map<String, Object> getPayload() {
63                 return Payload;
64         }
65
66         public void setPayload(Map<String, Object> payload) {
67                 Payload = payload;
68         }
69
70         @Override
71         public String toString() {
72                 return "Response [CommonHeader=" + CommonHeader + ", Status=" + Status + ", Payload=" + Payload + "]";
73         }
74         @Override
75         public int hashCode() {
76                 final int prime = 31;
77                 int result = 1;
78                 result = prime * result + ((CommonHeader == null) ? 0 : CommonHeader.hashCode());
79                 result = prime * result + ((Payload == null) ? 0 : Payload.hashCode());
80                 result = prime * result + ((Status == null) ? 0 : Status.hashCode());
81                 return result;
82         }
83         @Override
84         public boolean equals(Object obj) {
85                 if (this == obj)
86                         return true;
87                 if (obj == null)
88                         return false;
89                 if (getClass() != obj.getClass())
90                         return false;
91                 Response other = (Response) obj;
92                 if (CommonHeader == null) {
93                         if (other.CommonHeader != null)
94                                 return false;
95                 } else if (!CommonHeader.equals(other.CommonHeader))
96                         return false;
97                 if (Payload == null) {
98                         if (other.Payload != null)
99                                 return false;
100                 } else if (!Payload.equals(other.Payload))
101                         return false;
102                 if (Status == null) {
103                         if (other.Status != null)
104                                 return false;
105                 } else if (!Status.equals(other.Status))
106                         return false;
107                 return true;
108         }
109         
110         
111         
112 }