Updated region validation in multilang to be more readible

This commit is contained in:
Ryan Pelaez 2023-06-19 15:02:16 -07:00
parent 928a102ade
commit 985704a5ea

View file

@ -94,11 +94,8 @@ public class KinesisClientLibConfigurator {
Validate.isTrue(configuration.getKinesisCredentialsProvider().isDirty(), "A basic set of AWS credentials must be provided"); Validate.isTrue(configuration.getKinesisCredentialsProvider().isDirty(), "A basic set of AWS credentials must be provided");
//Verify Region is real //Verify Region is real
if(configuration.getKinesisClient().get("region") == null){ final String regionCode = String.valueOf(configuration.getKinesisClient().get("region"));
throw new NullPointerException("regionName must be passed in"); if (regionCode == null || Region.regions().stream().filter(x -> x.id().equalsIgnoreCase(regionCode)).count() == 0) {
}
final String regionCode = configuration.getKinesisClient().get("region").toString();
if (Region.regions().stream().filter(x -> x.id().equalsIgnoreCase(regionCode)).count() == 0) {
throw new IllegalArgumentException(String.format("Unsupported region: %s", regionCode)); throw new IllegalArgumentException(String.format("Unsupported region: %s", regionCode));
} }
return configuration; return configuration;