2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actorserviceprovider;
23 public enum OperationFinalResult {
25 * The Control Loop Policy successfully completed its Operations.
27 FINAL_SUCCESS("Final_Success"),
29 * The Control Loop Policy was an Open Loop and is finished.
31 FINAL_OPENLOOP("Final_OpenLoop"),
33 * The Control Loop Policy failed in its last Operation Policy. NOTE: Previous Operation Policies may have been
36 FINAL_FAILURE("Final_Failure"),
38 * The Control Loop Policy failed because the overall timeout was met.
40 FINAL_FAILURE_TIMEOUT("Final_Failure_Timeout"),
42 * The Control Loop Policy failed because an Operation Policy met its retry limit.
44 FINAL_FAILURE_RETRIES("Final_Failure_Retries"),
46 * The Control Loop Policy failed due to an exception.
48 FINAL_FAILURE_EXCEPTION("Final_Failure_Exception"),
50 * The Control Loop Policy failed due to guard denied.
52 FINAL_FAILURE_GUARD("Final_Failure_Guard");
56 private OperationFinalResult(String result) {
61 * Converts to a result object.
63 * @param result input string
64 * @return result object
66 public static OperationFinalResult toResult(String result) {
67 if (result.equalsIgnoreCase(FINAL_SUCCESS.toString())) {
70 if (result.equalsIgnoreCase(FINAL_OPENLOOP.toString())) {
71 return FINAL_OPENLOOP;
73 if (result.equalsIgnoreCase(FINAL_FAILURE.toString())) {
76 if (result.equalsIgnoreCase(FINAL_FAILURE_TIMEOUT.toString())) {
77 return FINAL_FAILURE_TIMEOUT;
79 if (result.equalsIgnoreCase(FINAL_FAILURE_RETRIES.toString())) {
80 return FINAL_FAILURE_RETRIES;
82 if (result.equalsIgnoreCase(FINAL_FAILURE_EXCEPTION.toString())) {
83 return FINAL_FAILURE_EXCEPTION;
85 if (result.equalsIgnoreCase(FINAL_FAILURE_GUARD.toString())) {
86 return FINAL_FAILURE_GUARD;
92 * Check if the result really is a result.
94 * @param result string
95 * @param finalResult result object
96 * @return true if a result
98 public static boolean isResult(String result, OperationFinalResult finalResult) {
99 OperationFinalResult toResult = OperationFinalResult.toResult(result);
100 if (toResult == null) {
103 return toResult.equals(finalResult);