2 * ============LICENSE_START=======================================================
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
24 package org.onap.policy.sdnr;
26 import java.io.Serializable;
27 import lombok.AccessLevel;
28 import lombok.AllArgsConstructor;
30 import org.onap.policy.sdnr.util.StatusCodeEnum;
32 @AllArgsConstructor(access = AccessLevel.PROTECTED)
33 public class PciResponseCode implements Serializable {
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;
46 private final int code;
49 public String toString() {
50 return Integer.toString(this.code);
54 * Translates the code to a string value that represents the meaning of the code.
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
59 public static String toResponseValue(int code) {
60 var statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
61 return (statusCodeEnum != null) ? statusCodeEnum.toString() : null;