Replaced all tabs with spaces in java and pom.xml
[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 that the vnf
27  * adapter can more easily utilize. This will ensure we get an object back. Any status code other than 200 will be
28  * treated as a failure. We may still get a 200 back - but the ValetStatus.status is "failed" - which will also be
29  * treated as a failure. The T class is expected to be one of the Valet*Response pojos.
30  */
31 public class GenericValetResponse<T> {
32     private int statusCode;
33     private String errorMessage;
34     private T returnObject;
35
36
37     public GenericValetResponse(int statusCode, String errorMessage, T obj) {
38         super();
39         this.statusCode = statusCode;
40         this.errorMessage = errorMessage;
41         this.returnObject = obj;
42     }
43
44     public GenericValetResponse() {
45         this(-1, "not set", null);
46     }
47
48     @Override
49     public String toString() {
50         return new ToStringBuilder(this).append("statusCode", statusCode).append("errorMessage", errorMessage)
51                 .append("returnObject", returnObject).toString();
52     }
53
54     public void setErrorMessage(String errorMessage) {
55         this.errorMessage = errorMessage;
56     }
57
58     public String getErrorMessage() {
59         return this.errorMessage;
60     }
61
62     public void setStatusCode(int statusCode) {
63         this.statusCode = statusCode;
64     }
65
66     public int getStatusCode() {
67         return this.statusCode;
68     }
69
70     public void setReturnObject(T obj) {
71         this.returnObject = obj;
72     }
73
74     public T getReturnObject() {
75         return this.returnObject;
76     }
77
78 }
79