@@ -344,8 +344,8 @@ public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableL
344
344
@ Nullable
345
345
private Resource resolvePropertySourceLocation (String location ) {
346
346
try {
347
- String resolvedLocation = (this .environment != null
348
- ? this .environment .resolveRequiredPlaceholders (location ) : location );
347
+ String resolvedLocation = (this .environment != null ?
348
+ this .environment .resolveRequiredPlaceholders (location ) : location );
349
349
return this .resourceLoader .getResource (resolvedLocation );
350
350
}
351
351
catch (Exception ex ) {
@@ -598,15 +598,11 @@ public void applyTo(GenerationContext generationContext,
598
598
599
599
Map <String , String > mappings = buildImportAwareMappings ();
600
600
if (!mappings .isEmpty ()) {
601
- GeneratedMethod generatedMethod = beanFactoryInitializationCode
602
- .getMethods ()
603
- .add ("addImportAwareBeanPostProcessors" , method ->
604
- generateAddPostProcessorMethod (method , mappings ));
605
- beanFactoryInitializationCode
606
- .addInitializer (generatedMethod .toMethodReference ());
601
+ GeneratedMethod generatedMethod = beanFactoryInitializationCode .getMethods ().add (
602
+ "addImportAwareBeanPostProcessors" , method -> generateAddPostProcessorMethod (method , mappings ));
603
+ beanFactoryInitializationCode .addInitializer (generatedMethod .toMethodReference ());
607
604
ResourceHints hints = generationContext .getRuntimeHints ().resources ();
608
- mappings .forEach (
609
- (target , from ) -> hints .registerType (TypeReference .of (from )));
605
+ mappings .forEach ((target , from ) -> hints .registerType (TypeReference .of (from )));
610
606
}
611
607
}
612
608
@@ -635,8 +631,7 @@ private CodeBlock generateAddPostProcessorCode(Map<String, String> mappings) {
635
631
}
636
632
637
633
private Map <String , String > buildImportAwareMappings () {
638
- ImportRegistry importRegistry = this .beanFactory
639
- .getBean (IMPORT_REGISTRY_BEAN_NAME , ImportRegistry .class );
634
+ ImportRegistry importRegistry = this .beanFactory .getBean (IMPORT_REGISTRY_BEAN_NAME , ImportRegistry .class );
640
635
Map <String , String > mappings = new LinkedHashMap <>();
641
636
for (String name : this .beanFactory .getBeanDefinitionNames ()) {
642
637
Class <?> beanType = this .beanFactory .getType (name );
@@ -671,11 +666,9 @@ private static class PropertySourcesAotContribution implements BeanFactoryInitia
671
666
@ Override
672
667
public void applyTo (GenerationContext generationContext , BeanFactoryInitializationCode beanFactoryInitializationCode ) {
673
668
registerRuntimeHints (generationContext .getRuntimeHints ());
674
- GeneratedMethod generatedMethod = beanFactoryInitializationCode
675
- .getMethods ()
669
+ GeneratedMethod generatedMethod = beanFactoryInitializationCode .getMethods ()
676
670
.add ("processPropertySources" , this ::generateAddPropertySourceProcessorMethod );
677
- beanFactoryInitializationCode
678
- .addInitializer (generatedMethod .toMethodReference ());
671
+ beanFactoryInitializationCode .addInitializer (generatedMethod .toMethodReference ());
679
672
}
680
673
681
674
private void registerRuntimeHints (RuntimeHints hints ) {
@@ -686,8 +679,8 @@ private void registerRuntimeHints(RuntimeHints hints) {
686
679
}
687
680
for (String location : descriptor .locations ()) {
688
681
Resource resource = this .resourceResolver .apply (location );
689
- if (resource != null && resource .exists () && resource instanceof ClassPathResource classpathResource ) {
690
- hints .resources ().registerPattern (classpathResource .getPath ());
682
+ if (resource instanceof ClassPathResource classPathResource && classPathResource .exists ()) {
683
+ hints .resources ().registerPattern (classPathResource .getPath ());
691
684
}
692
685
}
693
686
}
@@ -723,8 +716,8 @@ private CodeBlock generatePropertySourceDescriptorCode(PropertySourceDescriptor
723
716
code .add ("new $T(" , PropertySourceDescriptor .class );
724
717
CodeBlock values = descriptor .locations ().stream ()
725
718
.map (value -> CodeBlock .of ("$S" , value )).collect (CodeBlock .joining (", " ));
726
- if (descriptor .name () == null && descriptor .propertySourceFactory () == null
727
- && descriptor .encoding () == null && !descriptor .ignoreResourceNotFound ()) {
719
+ if (descriptor .name () == null && descriptor .propertySourceFactory () == null &&
720
+ descriptor .encoding () == null && !descriptor .ignoreResourceNotFound ()) {
728
721
code .add ("$L)" , values );
729
722
}
730
723
else {
0 commit comments