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,36 @@ 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 or apply the "
511+ + "'underscoresInNameBehavior' customization for this service (Supported "
512+ + "'underscoresInNameBehavior' values: %s)." , name , location , supportedBehaviors )
513+ ));
514+ }
515+ if (behavior != UnderscoresInNameBehavior .ALLOW ) {
516+ throw ModelInvalidException .fromEntry (ValidationEntry .create (
517+ ValidationErrorId .INVALID_CODEGEN_CUSTOMIZATION ,
518+ ValidationErrorSeverity .DANGER ,
519+ String .format (
520+ "Unsupported underscoresInShapeNameBehavior: %s. Supported values: %s" ,
521+ behavior , supportedBehaviors )
522+ ));
523+ }
508524 }
509525
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 );
526+ if (!VALID_IDENTIFIER_NAME .matcher (name ).matches ()) {
527+ throw ModelInvalidException .fromEntry (ValidationEntry .create (
528+ ValidationErrorId .INVALID_IDENTIFIER_NAME ,
529+ ValidationErrorSeverity .DANGER ,
530+ String .format (
531+ "Encountered a name or identifier that is invalid within Java (%s in %s). Please remove invalid "
532+ + "characters." , name , location )
533+ ));
534+ }
513535 }
514536}
0 commit comments