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