21750e1bd6e27e3547453ef29bfe3eb46154acd6
[policy/drools-applications.git] / controlloop / common / 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  * ================================================================================
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.sdnr;
22
23 import com.google.gson.annotations.SerializedName;
24
25 import java.io.Serializable;
26
27 public class PciResponse implements Serializable {
28
29     private static final long serialVersionUID = 8375708697287669750L;
30
31     @SerializedName(value = "CommonHeader")
32     private PciCommonHeader commonHeader;
33
34     @SerializedName(value = "Status")
35     private Status status = new Status();
36
37     @SerializedName(value = "Payload")
38     private String payload;
39
40     public PciResponse() {
41         // EMPTY
42     }
43
44     /**
45      * Constructs a response using the common header of the request since they will
46      * be the same.
47      * 
48      * @param request
49      *            an sdnr Pci request object specified by the Pci api guide
50      */
51     public PciResponse(PciRequest request) {
52         this.commonHeader = new PciCommonHeader(request.getCommonHeader());
53
54     }
55
56     /**
57      * Get the common header.
58      * 
59      * @return the commonHeader
60      */
61     public PciCommonHeader getCommonHeader() {
62         return commonHeader;
63     }
64
65     /**
66      * Set the common header.
67      * 
68      * @param commonHeader
69      *            the commonHeader to set
70      */
71     public void setCommonHeader(PciCommonHeader commonHeader) {
72         this.commonHeader = commonHeader;
73     }
74
75     /**
76      * Get the status.
77      * 
78      * @return the status
79      */
80     public Status getStatus() {
81         return status;
82     }
83
84     /**
85      * Set the status.
86      * 
87      * @param status
88      *            the status to set
89      */
90     public void setStatus(Status status) {
91         this.status = status;
92     }
93
94     /**
95      * Get the payload.
96      * 
97      * @return the payload
98      */
99
100     public String getPayload() {
101         return payload;
102     }
103
104     public void setPayload(String payload) {
105         this.payload = payload;
106     }
107
108     @Override
109     public String toString() {
110         return "PciResponse[CommonHeader=" + commonHeader + ", Status=" + status + ", Payload="
111                 + payload + "]";
112     }
113
114     @Override
115     public int hashCode() {
116         final int prime = 31;
117         int result = 1;
118         result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
119         result = prime * result + ((payload == null) ? 0 : payload.hashCode());
120         result = prime * result + ((status == null) ? 0 : status.hashCode());
121         return result;
122     }
123
124     @Override
125     public boolean equals(Object obj) {
126         if (this == obj) {
127             return true;
128         }
129         if (obj == null) {
130             return false;
131         }
132         if (getClass() != obj.getClass()) {
133             return false;
134         }
135         PciResponse other = (PciResponse) obj;
136         if (commonHeader == null) {
137             if (other.commonHeader != null) {
138                 return false;
139             }
140         } else if (!commonHeader.equals(other.commonHeader)) {
141             return false;
142         }
143         if (payload == null) {
144             if (other.payload != null) {
145                 return false;
146             }
147         } else if (!payload.equals(other.payload)) {
148             return false;
149         }
150         if (status == null) {
151             if (other.status != null) {
152                 return false;
153             }
154         } else if (!status.equals(other.status)) {
155             return false;
156         }
157         return true;
158     }
159 }