* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package org.onap.policy.appc;
import com.google.gson.annotations.SerializedName;
-
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+@Getter
+@Setter
+@EqualsAndHashCode
public class Response implements Serializable {
+
private static final long serialVersionUID = 434953706339865151L;
@SerializedName("CommonHeader")
private CommonHeader commonHeader;
+ /**
+ * This should only be populated if the incoming message actually has a "Status"
+ * field. Otherwise, actor.appc will be unable to use this to distinguish between
+ * Request and Response objects.
+ */
@SerializedName("Status")
- private ResponseStatus status = new ResponseStatus();
+ private ResponseStatus status;
@SerializedName("Payload")
- private HashMap<String, Object> payload = new HashMap<>();
+ private Map<String, Object> payload = new HashMap<>();
public Response() {
/**
* Construct an instance from an existing instance.
- *
+ *
* @param request the existing instance
*/
public Response(Request request) {
}
}
- public CommonHeader getCommonHeader() {
- return commonHeader;
- }
-
- public void setCommonHeader(CommonHeader commonHeader) {
- this.commonHeader = commonHeader;
- }
-
- public ResponseStatus getStatus() {
- return status;
- }
-
- public void setStatus(ResponseStatus status) {
- this.status = status;
- }
-
- public Map<String, Object> getPayload() {
- return payload;
- }
-
- public void setPayload(Map<String, Object> payload) {
- this.payload = new HashMap<>(payload);
- }
-
@Override
public String toString() {
return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
- result = prime * result + ((payload == null) ? 0 : payload.hashCode());
- result = prime * result + ((status == null) ? 0 : status.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Response other = (Response) obj;
- if (commonHeader == null) {
- if (other.commonHeader != null) {
- return false;
- }
- } else if (!commonHeader.equals(other.commonHeader)) {
- return false;
- }
- if (payload == null) {
- if (other.payload != null) {
- return false;
- }
- } else if (!payload.equals(other.payload)) {
- return false;
- }
- if (status == null) {
- if (other.status != null) {
- return false;
- }
- } else if (!status.equals(other.status)) {
- return false;
- }
- return true;
- }
-
-
-
}