43
43
import software .amazon .awssdk .codegen .model .intermediate .Metadata ;
44
44
import software .amazon .awssdk .codegen .model .service .ServiceModel ;
45
45
import 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 ;
46
50
import software .amazon .awssdk .utils .Logger ;
47
51
import software .amazon .awssdk .utils .StringUtils ;
48
- import software .amazon .awssdk .utils .Validate ;
49
52
50
53
/**
51
54
* Default implementation of naming strategy respecting.
@@ -498,17 +501,35 @@ private void validateCustomerVisibleName(String name, String location) {
498
501
UnderscoresInNameBehavior behavior = customizationConfig .getUnderscoresInNameBehavior ();
499
502
500
503
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
+ }
508
523
}
509
524
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
+ }
513
534
}
514
535
}
0 commit comments