1 /*
2  * Copyright 2011-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *    http://aws.amazon.com/apache2.0
9  *
10  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
11  * OR CONDITIONS OF ANY KIND, either express or implied. See the
12  * License for the specific language governing permissions and
13  * limitations under the License.
14  */

15
16 package com.amazonaws.retry;
17
18 /**
19  * The retry mode
20  */

21 public enum RetryMode {
22
23     /**
24      * The legacy mode that only enables throttled retry for transient errors
25      */

26     LEGACY("legacy"),
27
28     /**
29      * Standard mode is built on top of legacy mode and has throttled retry enabled for throttling errors apart from transient
30      * errors. In addition, timeout(socket timeout or connection timeout) errors would cost more retry capacity compared with
31      * {@link #LEGACY}.
32      */

33     STANDARD("standard");
34
35     private final String name;
36
37     RetryMode(String name) {
38         this.name = name;
39     }
40
41     public String getName() {
42         return name;
43     }
44
45     /**
46      * Returns a retry mode enum corresponding to the given retryMode name.
47      *
48      * @param value The name of the retry mode
49      * @return RetryMode enum representing the given retry mode name.
50      */

51     public static RetryMode fromName(String value) {
52         if (value == null) {
53             return null;
54         }
55
56         for (RetryMode retryMode : RetryMode.values()) {
57             if (retryMode.getName().equalsIgnoreCase(value)) {
58                 return retryMode;
59             }
60         }
61
62         return null;
63     }
64 }
65