0

Im using the AWS api in my groovy script:

new AmazonDynamoDBClientBuilder ()
            .withRegion(Regions.SA_EAST_1)
            .build()

I want to be able to pass in the region to the script as a user argument but Regions is an enum. How can I pass the region (like "SA_EAST_1" or "CN_NORTH_1") as a string? I could have my own map to convert the string values to the enum values but that seems really dumb.

red888
  • 27,709
  • 55
  • 204
  • 392

1 Answers1

2
    // convert the enum value to a string using name
    String name = Region.SA_EAST_1.name();
    // convert the string to a enum value
    Region value = Region.valueOf(name);
IEE1394
  • 1,181
  • 13
  • 33