move actors code in drools-applications to policy/models
[policy/models.git] / models-interactions / model-impl / sdnr / src / main / java / org / onap / policy / sdnr / PciResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdnr
4  * ================================================================================
5  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.sdnr;
23
24 import com.google.gson.annotations.SerializedName;
25
26 import java.io.Serializable;
27
28 public class PciResponse implements Serializable {
29
30     private static final long serialVersionUID = 8375708697287669750L;
31
32     @SerializedName(value = "CommonHeader")
33     private PciCommonHeader commonHeader;
34
35     @SerializedName(value = "Status")
36     private Status status = new Status();
37
38     @SerializedName(value = "Payload")
39     private String payload;
40
41     public PciResponse() {
42         // EMPTY
43     }
44
45     /**
46      * Constructs a response using the common header of the request since they will
47      * be the same.
48      *
49      * @param request
50      *            an sdnr Pci request object specified by the Pci api guide
51      */
52     public PciResponse(PciRequest request) {
53         this.commonHeader = new PciCommonHeader(request.getCommonHeader());
54
55     }
56
57     /**
58      * Get the common header.
59      *
60      * @return the commonHeader
61      */
62     public PciCommonHeader getCommonHeader() {
63         return commonHeader;
64     }
65
66     /**
67      * Set the common header.
68      *
69      * @param commonHeader
70      *            the commonHeader to set
71      */
72     public void setCommonHeader(PciCommonHeader commonHeader) {
73         this.commonHeader = commonHeader;
74     }
75
76     /**
77      * Get the status.
78      *
79      * @return the status
80      */
81     public Status getStatus() {
82         return status;
83     }
84
85     /**
86      * Set the status.
87      *
88      * @param status
89      *            the status to set
90      */
91     public void setStatus(Status status) {
92         this.status = status;
93     }
94
95     /**
96      * Get the payload.
97      *
98      * @return the payload
99      */
100
101     public String getPayload() {
102         return payload;
103     }
104
105     public void setPayload(String payload) {
106         this.payload = payload;
107     }
108
109     @Override
110     public String toString() {
111         return "PciResponse[CommonHeader=" + commonHeader + ", Status=" + status + ", Payload="
112                 + payload + "]";
113     }
114
115     @Override
116     public int hashCode() {
117         final int prime = 31;
118         int result = 1;
119         result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
120         result = prime * result + ((payload == null) ? 0 : payload.hashCode());
121         result = prime * result + ((status == null) ? 0 : status.hashCode());
122         return result;
123     }
124
125     @Override
126     public boolean equals(Object obj) {
127         if (this == obj) {
128             return true;
129         }
130         if (obj == null) {
131             return false;
132         }
133         if (getClass() != obj.getClass()) {
134             return false;
135         }
136         PciResponse other = (PciResponse) obj;
137         if (commonHeader == null) {
138             if (other.commonHeader != null) {
139                 return false;
140             }
141         } else if (!commonHeader.equals(other.commonHeader)) {
142             return false;
143         }
144         if (payload == null) {
145             if (other.payload != null) {
146                 return false;
147             }
148         } else if (!payload.equals(other.payload)) {
149             return false;
150         }
151         if (status == null) {
152             if (other.status != null) {
153                 return false;
154             }
155         } else if (!status.equals(other.status)) {
156             return false;
157         }
158         return true;
159     }
160 }