1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/codedeploy/model/TrafficRoutingType.h>
7 #include <aws/core/utils/HashingUtils.h>
8 #include <aws/core/Globals.h>
9 #include <aws/core/utils/EnumParseOverflowContainer.h>
10 
11 using namespace Aws::Utils;
12 
13 
14 namespace Aws
15 {
16   namespace CodeDeploy
17   {
18     namespace Model
19     {
20       namespace TrafficRoutingTypeMapper
21       {
22 
23         static const int TimeBasedCanary_HASH = HashingUtils::HashString("TimeBasedCanary");
24         static const int TimeBasedLinear_HASH = HashingUtils::HashString("TimeBasedLinear");
25         static const int AllAtOnce_HASH = HashingUtils::HashString("AllAtOnce");
26 
27 
GetTrafficRoutingTypeForName(const Aws::String & name)28         TrafficRoutingType GetTrafficRoutingTypeForName(const Aws::String& name)
29         {
30           int hashCode = HashingUtils::HashString(name.c_str());
31           if (hashCode == TimeBasedCanary_HASH)
32           {
33             return TrafficRoutingType::TimeBasedCanary;
34           }
35           else if (hashCode == TimeBasedLinear_HASH)
36           {
37             return TrafficRoutingType::TimeBasedLinear;
38           }
39           else if (hashCode == AllAtOnce_HASH)
40           {
41             return TrafficRoutingType::AllAtOnce;
42           }
43           EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
44           if(overflowContainer)
45           {
46             overflowContainer->StoreOverflow(hashCode, name);
47             return static_cast<TrafficRoutingType>(hashCode);
48           }
49 
50           return TrafficRoutingType::NOT_SET;
51         }
52 
GetNameForTrafficRoutingType(TrafficRoutingType enumValue)53         Aws::String GetNameForTrafficRoutingType(TrafficRoutingType enumValue)
54         {
55           switch(enumValue)
56           {
57           case TrafficRoutingType::TimeBasedCanary:
58             return "TimeBasedCanary";
59           case TrafficRoutingType::TimeBasedLinear:
60             return "TimeBasedLinear";
61           case TrafficRoutingType::AllAtOnce:
62             return "AllAtOnce";
63           default:
64             EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
65             if(overflowContainer)
66             {
67               return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
68             }
69 
70             return {};
71           }
72         }
73 
74       } // namespace TrafficRoutingTypeMapper
75     } // namespace Model
76   } // namespace CodeDeploy
77 } // namespace Aws
78