2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.appc;
23 import com.google.gson.annotations.SerializedName;
25 import java.io.Serializable;
26 import java.util.HashMap;
29 public class Response implements Serializable {
30 private static final long serialVersionUID = 434953706339865151L;
32 @SerializedName("CommonHeader")
33 private CommonHeader commonHeader;
35 @SerializedName("Status")
36 private ResponseStatus status = new ResponseStatus();
38 @SerializedName("Payload")
39 private HashMap<String, Object> payload = new HashMap<>();
46 * Construct an instance from an existing instance.
48 * @param request the existing instance
50 public Response(Request request) {
51 if (request.getCommonHeader() != null) {
52 this.commonHeader = new CommonHeader(request.getCommonHeader());
54 if (request.getPayload() != null) {
55 this.payload.putAll(request.getPayload());
59 public CommonHeader getCommonHeader() {
63 public void setCommonHeader(CommonHeader commonHeader) {
64 this.commonHeader = commonHeader;
67 public ResponseStatus getStatus() {
71 public void setStatus(ResponseStatus status) {
75 public Map<String, Object> getPayload() {
79 public void setPayload(Map<String, Object> payload) {
80 this.payload = new HashMap<>(payload);
84 public String toString() {
85 return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]";
89 public int hashCode() {
92 result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
93 result = prime * result + ((payload == null) ? 0 : payload.hashCode());
94 result = prime * result + ((status == null) ? 0 : status.hashCode());
99 public boolean equals(Object obj) {
106 if (getClass() != obj.getClass()) {
109 Response other = (Response) obj;
110 if (commonHeader == null) {
111 if (other.commonHeader != null) {
114 } else if (!commonHeader.equals(other.commonHeader)) {
117 if (payload == null) {
118 if (other.payload != null) {
121 } else if (!payload.equals(other.payload)) {
124 if (status == null) {
125 if (other.status != null) {
128 } else if (!status.equals(other.status)) {