Remove unused imports in models
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / main / java / org / onap / policy / controlloop / actorserviceprovider / OperationResult.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.controlloop.actorserviceprovider;
22
23 public enum OperationResult {
24     /**
25      * Operation was successful.
26      */
27     SUCCESS("Success"),
28     /**
29      * Operation failed.
30      */
31     FAILURE("Failure"),
32     /**
33      * Operation failed due to maximum retries being met.
34      */
35     FAILURE_RETRIES("Failure_Retries"),
36     /**
37      * Operation failed due to timeout occurring.
38      */
39     FAILURE_TIMEOUT("Failure_Timeout"),
40     /**
41      * Operation failed due to an exception.
42      */
43     FAILURE_EXCEPTION("Failure_Exception"),
44     /**
45      * Operation failed since Guard did not permit.
46      */
47     FAILURE_GUARD("Failure_Guard")
48     ;
49
50     private String result;
51
52     private OperationResult(String result) {
53         this.result = result;
54     }
55
56     @Override
57     public String toString() {
58         return this.result;
59     }
60
61     /**
62      * Convert to a result.
63      *
64      * @param result result string
65      * @return Result object
66      */
67     public static OperationResult toResult(String result) {
68         if (result.equalsIgnoreCase(SUCCESS.toString())) {
69             return SUCCESS;
70         }
71         if (result.equalsIgnoreCase(FAILURE.toString())) {
72             return FAILURE;
73         }
74         if (result.equalsIgnoreCase(FAILURE_RETRIES.toString())) {
75             return FAILURE_RETRIES;
76         }
77         if (result.equalsIgnoreCase(FAILURE_TIMEOUT.toString())) {
78             return FAILURE_TIMEOUT;
79         }
80         if (result.equalsIgnoreCase(FAILURE_EXCEPTION.toString())) {
81             return FAILURE_EXCEPTION;
82         }
83         if (result.equalsIgnoreCase(FAILURE_GUARD.toString())) {
84             return FAILURE_GUARD;
85         }
86         return null;
87     }
88 }