a9b158525e6d354cdb2dcc8de7f4ec9349028315
[ui/dmaapbc.git] /
1 /*-
2  * ================================================================================
3  * DCAE DMaaP Bus Controller REST Client
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
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  * ================================================================================
19  */
20 package org.openecomp.dcae.dmaapbc.client;
21
22 /**
23  * Holds the status code and body that result from accessing an HTTP URL.
24  */
25 public class HttpStatusAndResponse<ResponseType> {
26
27         private int statusCode;
28         private ResponseType response;
29
30         public HttpStatusAndResponse(int status, ResponseType resp) {
31                 this.statusCode = status;
32                 this.response = resp;
33         }
34
35         public int getStatusCode() {
36                 return statusCode;
37         }
38
39         public void setStatusCode(final int code) {
40                 this.statusCode = code;
41         }
42
43         public ResponseType getResponse() {
44                 return response;
45         }
46
47         public void setResponse(ResponseType response) {
48                 this.response = response;
49         }
50
51         /**
52          * Convenience method to avoid testing for null and calling .toString()
53          * 
54          * @return String version of the response object; null if the object is
55          *         null.
56          */
57         public String getResponseString() {
58                 return response == null ? null : response.toString();
59         }
60
61         @Override
62         public String toString() {
63                 return "HttpStatusAndResponse[" + Integer.toString(statusCode) + ";"
64                                 + (response == null ? "" : response.toString()) + "]";
65         }
66 }