[PORTAL-7] Rebase
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / ecomp / model / PortalRestResponse.java
1 /*-\r
2  * ================================================================================\r
3  * ECOMP Portal\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ================================================================================\r
19  */\r
20 package org.openecomp.portalapp.portal.ecomp.model;\r
21 \r
22 public class PortalRestResponse<T> {\r
23         \r
24         private PortalRestStatusEnum status;\r
25         private String message;\r
26         \r
27         private T response;\r
28         \r
29         public PortalRestResponse(){};\r
30         \r
31         public PortalRestResponse(PortalRestStatusEnum status, String message, T response){\r
32                 this.status = status;\r
33                 this.message = message;\r
34                 this.response = response;\r
35         }\r
36 \r
37         public PortalRestStatusEnum getStatus() {\r
38                 return status;\r
39         }\r
40 \r
41         public void setStatus(PortalRestStatusEnum status) {\r
42                 this.status = status;\r
43         }\r
44 \r
45         public String getMessage() {\r
46                 return message;\r
47         }\r
48 \r
49         public void setMessage(String message) {\r
50                 this.message = message;\r
51         }\r
52 \r
53         public T getResponse() {\r
54                 return response;\r
55         }\r
56 \r
57         public void setResponse(T response) {\r
58                 this.response = response;\r
59         }\r
60 \r
61         @Override\r
62         public String toString() {\r
63                 return "PortalRestResponse [status=" + status + ", message=" + message + ", response=" + response + "]";\r
64         }\r
65 \r
66         @Override\r
67         public int hashCode() {\r
68                 final int prime = 31;\r
69                 int result = 1;\r
70                 result = prime * result + ((message == null) ? 0 : message.hashCode());\r
71                 result = prime * result + ((response == null) ? 0 : response.hashCode());\r
72                 result = prime * result + ((status == null) ? 0 : status.hashCode());\r
73                 return result;\r
74         }\r
75 \r
76         @Override\r
77         public boolean equals(Object obj) {\r
78                 if (this == obj)\r
79                         return true;\r
80                 if (obj == null)\r
81                         return false;\r
82                 if (getClass() != obj.getClass())\r
83                         return false;\r
84                 PortalRestResponse other = (PortalRestResponse) obj;\r
85                 if (message == null) {\r
86                         if (other.message != null)\r
87                                 return false;\r
88                 } else if (!message.equals(other.message))\r
89                         return false;\r
90                 if (response == null) {\r
91                         if (other.response != null)\r
92                                 return false;\r
93                 } else if (!response.equals(other.response))\r
94                         return false;\r
95                 if (status != other.status)\r
96                         return false;\r
97                 return true;\r
98         };      \r
99         \r
100         \r
101 }\r