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 org.onap.policy.sdnr.util.StatusCodeEnum;
29 public class PciResponseCode implements Serializable {
31 /* These fields define the key to the response code value. */
32 public static final String ACCEPTED = "ACCEPTED";
33 public static final String ERROR = "ERROR";
34 public static final String REJECT = "REJECT";
35 public static final String SUCCESS = "SUCCESS";
36 public static final String FAILURE = "FAILURE";
37 public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS";
38 public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
39 private static final long serialVersionUID = -5371924429933449763L;
41 private final Integer code;
43 protected PciResponseCode(final int code) {
47 public int getCode() {
52 public String toString() {
53 return Integer.toString(this.code);
57 * Translates the code to a string value that represents the meaning of the code.
59 * @param code the numeric value that is returned by SDNR based on success, failure, etc. of the action requested
60 * @return the string value equivalent of the SDNR response code
62 public static String toResponseValue(int code) {
63 var statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
64 return (statusCodeEnum != null) ? statusCodeEnum.toString() : null;