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.appclcm;
23 import com.google.gson.annotations.SerializedName;
25 import java.io.Serializable;
27 public class LcmResponse implements Serializable {
29 private static final long serialVersionUID = 6332508597287669750L;
31 @SerializedName(value = "common-header")
32 private LcmCommonHeader commonHeader;
34 @SerializedName(value = "status")
35 private LcmResponseStatus status = new LcmResponseStatus();
37 @SerializedName(value = "payload")
38 private String payload;
40 public LcmResponse() {
45 * Constructs a response using the common header of the request since they will be the same.
47 * @param request an appc lcm request object specified by the lcm api guide
49 public LcmResponse(LcmRequest request) {
50 this.commonHeader = new LcmCommonHeader(request.getCommonHeader());
51 String requestPayload = request.getPayload();
52 if (requestPayload != null) {
53 this.payload = requestPayload;
58 * Get the common header.
60 * @return the commonHeader
62 public LcmCommonHeader getCommonHeader() {
67 * Set the common header.
69 * @param commonHeader the commonHeader to set
71 public void setCommonHeader(LcmCommonHeader commonHeader) {
72 this.commonHeader = commonHeader;
80 public LcmResponseStatus getStatus() {
87 * @param status the status to set
89 public void setStatus(LcmResponseStatus status) {
98 public String getPayload() {
105 * @param payload the payload to set
107 public void setPayload(String payload) {
108 this.payload = payload;
112 public String toString() {
113 return "Response [commonHeader=" + commonHeader + ", status=" + status + ", payload=" + payload + "]";
117 public int hashCode() {
118 final int prime = 31;
120 result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
121 result = prime * result + ((payload == null) ? 0 : payload.hashCode());
122 result = prime * result + ((status == null) ? 0 : status.hashCode());
127 public boolean equals(Object obj) {
134 if (getClass() != obj.getClass()) {
137 LcmResponse other = (LcmResponse) obj;
138 if (commonHeader == null) {
139 if (other.commonHeader != null) {
142 } else if (!commonHeader.equals(other.commonHeader)) {
145 if (payload == null) {
146 if (other.payload != null) {
149 } else if (!payload.equals(other.payload)) {
152 if (status == null) {
153 if (other.status != null) {
156 } else if (!status.equals(other.status)) {