4343import software .amazon .awssdk .codegen .model .intermediate .Metadata ;
4444import software .amazon .awssdk .codegen .model .service .ServiceModel ;
4545import software .amazon .awssdk .codegen .model .service .Shape ;
46+ import software .amazon .awssdk .codegen .validation .ModelInvalidException ;
47+ import software .amazon .awssdk .codegen .validation .ValidationEntry ;
48+ import software .amazon .awssdk .codegen .validation .ValidationErrorId ;
49+ import software .amazon .awssdk .codegen .validation .ValidationErrorSeverity ;
4650import software .amazon .awssdk .utils .Logger ;
4751import software .amazon .awssdk .utils .StringUtils ;
48- import software .amazon .awssdk .utils .Validate ;
4952
5053/**
5154 * Default implementation of naming strategy respecting.
@@ -498,17 +501,35 @@ private void validateCustomerVisibleName(String name, String location) {
498501 UnderscoresInNameBehavior behavior = customizationConfig .getUnderscoresInNameBehavior ();
499502
500503 String supportedBehaviors = Arrays .toString (UnderscoresInNameBehavior .values ());
501- Validate .notNull (behavior ,
502- "Encountered a name or identifier that the customer will see (%s in the %s) with an underscore. "
503- + "This isn't idiomatic in Java. Please either remove the underscores or apply the "
504- + "'underscoresInNameBehavior' customization for this service (Supported "
505- + "'underscoresInNameBehavior' values: %s)." , name , location , supportedBehaviors );
506- Validate .isTrue (behavior == UnderscoresInNameBehavior .ALLOW ,
507- "Unsupported underscoresInShapeNameBehavior: %s. Supported values: %s" , behavior , supportedBehaviors );
504+ if (behavior == null ) {
505+ throw ModelInvalidException .fromEntry (ValidationEntry .create (
506+ ValidationErrorId .INVALID_IDENTIFIER_NAME ,
507+ ValidationErrorSeverity .DANGER ,
508+ String .format (
509+ "Encountered a name or identifier that the customer will see (%s in the %s) with an underscore. "
510+ + "This isn't idiomatic in Java. Please either remove the underscores" ,
511+ name , location , supportedBehaviors )
512+ ));
513+ }
514+ if (behavior != UnderscoresInNameBehavior .ALLOW ) {
515+ throw ModelInvalidException .fromEntry (ValidationEntry .create (
516+ ValidationErrorId .INVALID_CODEGEN_CUSTOMIZATION ,
517+ ValidationErrorSeverity .DANGER ,
518+ String .format (
519+ "Unsupported underscoresInShapeNameBehavior: %s. Supported values: %s" ,
520+ behavior , supportedBehaviors )
521+ ));
522+ }
508523 }
509524
510- Validate .isTrue (VALID_IDENTIFIER_NAME .matcher (name ).matches (),
511- "Encountered a name or identifier that is invalid within Java (%s in %s). Please remove invalid "
512- + "characters." , name , location );
525+ if (!VALID_IDENTIFIER_NAME .matcher (name ).matches ()) {
526+ throw ModelInvalidException .fromEntry (ValidationEntry .create (
527+ ValidationErrorId .INVALID_IDENTIFIER_NAME ,
528+ ValidationErrorSeverity .DANGER ,
529+ String .format (
530+ "Encountered a name or identifier that is invalid within Java (%s in %s). Please remove invalid "
531+ + "characters." , name , location )
532+ ));
533+ }
513534 }
514535}
0 commit comments