Remove dmaap from models
[policy/models.git] / models-interactions / model-impl / appclcm / src / main / java / org / onap / policy / appclcm / AppcLcmResponseCode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appclcm
4  * ================================================================================
5  * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.appclcm;
24
25 import java.io.Serializable;
26 import lombok.AccessLevel;
27 import lombok.AllArgsConstructor;
28 import lombok.Getter;
29 import org.onap.policy.appclcm.util.StatusCodeEnum;
30
31 @AllArgsConstructor(access = AccessLevel.PROTECTED)
32 public class AppcLcmResponseCode implements Serializable {
33
34     /* These fields define the key to the response code value. */
35     public static final String ACCEPTED = "ACCEPTED";
36     public static final String ERROR = "ERROR";
37     public static final String REJECT = "REJECT";
38     public static final String SUCCESS = "SUCCESS";
39     public static final String FAILURE = "FAILURE";
40     public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS";
41     public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
42     private static final long serialVersionUID = 8189456447227022582L;
43
44     @Getter
45     private final int code;
46
47     @Override
48     public String toString() {
49         return Integer.toString(this.code);
50     }
51
52     /**
53      * Translates the code to a string value that represents the meaning of the code.
54      *
55      * @param code the numeric value that is returned by APPC based on success, failure, etc. of the action requested
56      * @return the string value equivalent of the APPC response code
57      */
58     public static String toResponseValue(int code) {
59         var statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
60         return (statusCodeEnum != null) ? statusCodeEnum.toString() : null;
61     }
62 }