2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.sdnr;
24 import java.io.Serializable;
25 import org.onap.policy.sdnr.util.StatusCodeEnum;
27 public class PciResponseCode implements Serializable {
29 /* These fields define the key to the response code value. */
30 public static final String ACCEPTED = "ACCEPTED";
31 public static final String ERROR = "ERROR";
32 public static final String REJECT = "REJECT";
33 public static final String SUCCESS = "SUCCESS";
34 public static final String FAILURE = "FAILURE";
35 public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS";
36 public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
37 private static final long serialVersionUID = -5371924429933449763L;
39 private final Integer code;
41 protected PciResponseCode(final int code) {
45 public int getCode() {
50 public String toString() {
51 return Integer.toString(this.code);
55 * Translates the code to a string value that represents the meaning of the code.
57 * @param code the numeric value that is returned by SDNR based on success, failure, etc. of the action requested
58 * @return the string value equivalent of the SDNR response code
60 public static String toResponseValue(int code) {
61 StatusCodeEnum statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
62 return (statusCodeEnum != null) ? statusCodeEnum.toString() : null;