Containerization feature of SO
[so.git] / adapters / mso-openstack-adapters / src / main / java / org / onap / so / adapters / valet / GenericValetResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 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
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.so.adapters.valet;
22
23 import org.apache.commons.lang3.builder.ToStringBuilder;
24
25 /*
26  * The purpose of this class is to encapsulate the possible responses from Valet in to one generic class
27  * that the vnf adapter can more easily utilize. This will ensure we get an object back. Any status
28  * code other than 200 will be treated as a failure.  We may still get a 200 back - but the 
29  * ValetStatus.status is "failed" - which will also be treated as a failure. The T class is 
30  * expected to be one of the Valet*Response pojos.  
31  */
32 public class GenericValetResponse<T> {
33         private int statusCode;
34         private String errorMessage;
35         private T returnObject;
36         
37         @Override
38         public String toString() {
39                 return new ToStringBuilder(this).append("statusCode", statusCode).append("errorMessage", errorMessage)
40                                 .append("returnObject", returnObject).toString();
41         }
42         public GenericValetResponse(int statusCode, String errorMessage, T obj) {
43                 super();
44                 this.statusCode = statusCode;
45                 this.errorMessage = errorMessage;
46                 this.returnObject = obj;
47         }
48         public GenericValetResponse() {
49                 this(-1, "not set", null);
50         }
51         public void setErrorMessage(String errorMessage) {
52                 this.errorMessage = errorMessage;
53         }
54         public String getErrorMessage() {
55                 return this.errorMessage;
56         }
57         public void setStatusCode(int statusCode) {
58                 this.statusCode = statusCode;
59         }
60         public int getStatusCode() {
61                 return this.statusCode;
62         }
63         public void setReturnObject(T obj) {
64                 this.returnObject = obj;
65         }
66         public T getReturnObject() {
67                 return this.returnObject;
68         }
69         
70 }
71