53
53
* @author Mark Paluch
54
54
* @author Johannes Englmeier
55
55
* @author Florian Cramer
56
+ * @author Christoph Strobl
56
57
*/
57
58
public class AnnotationRepositoryConfigurationSource extends RepositoryConfigurationSourceSupport {
58
59
@@ -314,15 +315,10 @@ private static BeanNameGenerator configuredOrDefaultBeanNameGenerator(Annotation
314
315
Class <? extends Annotation > annotation , ClassLoader beanClassLoader ,
315
316
@ Nullable BeanNameGenerator importBeanNameGenerator ) {
316
317
317
- Map <String , Object > annotationAttributes = metadata .getAnnotationAttributes (annotation .getName ());
318
-
319
- if (annotationAttributes != null ) {
320
-
321
- BeanNameGenerator beanNameGenerator = getBeanNameGenerator (annotationAttributes , beanClassLoader );
318
+ BeanNameGenerator beanNameGenerator = getConfiguredBeanNameGenerator (metadata , annotation , beanClassLoader );
322
319
323
- if (beanNameGenerator != null ) {
324
- return beanNameGenerator ;
325
- }
320
+ if (beanNameGenerator != null ) {
321
+ return beanNameGenerator ;
326
322
}
327
323
328
324
return defaultBeanNameGenerator (importBeanNameGenerator );
@@ -348,26 +344,30 @@ private static BeanNameGenerator defaultBeanNameGenerator(@Nullable BeanNameGene
348
344
}
349
345
350
346
/**
351
- * Obtain a configured {@link BeanNameGenerator}.
347
+ * Obtain a configured {@link BeanNameGenerator} if present .
352
348
*
353
349
* @param beanClassLoader a class loader to load the configured {@link BeanNameGenerator} class in case it was
354
350
* configured as String instead of a Class instance.
355
- * @return the bean name generator.
351
+ * @return the bean name generator or {@literal null} if not configured .
356
352
*/
357
353
@ Nullable
358
354
@ SuppressWarnings ("unchecked" )
359
- private static BeanNameGenerator getBeanNameGenerator ( Map < String , Object > annotationAttributes ,
360
- ClassLoader beanClassLoader ) {
355
+ private static BeanNameGenerator getConfiguredBeanNameGenerator ( AnnotationMetadata metadata ,
356
+ Class <? extends Annotation > annotation , ClassLoader beanClassLoader ) {
361
357
362
- Object configuredBeanNameGenerator = annotationAttributes .get (BEAN_NAME_GENERATOR );
358
+ Map <String , Object > annotationAttributes = metadata .getAnnotationAttributes (annotation .getName ());
359
+ if (annotationAttributes == null || !annotationAttributes .containsKey (BEAN_NAME_GENERATOR )) {
360
+ return null ;
361
+ }
363
362
363
+ Object configuredBeanNameGenerator = annotationAttributes .get (BEAN_NAME_GENERATOR );
364
364
if (configuredBeanNameGenerator == null ) {
365
365
return null ;
366
366
}
367
367
368
- if (configuredBeanNameGenerator instanceof String cbng ) {
368
+ if (configuredBeanNameGenerator instanceof String beanNameGeneratorTypeName ) {
369
369
try {
370
- configuredBeanNameGenerator = ClassUtils .forName (cbng , beanClassLoader );
370
+ configuredBeanNameGenerator = ClassUtils .forName (beanNameGeneratorTypeName , beanClassLoader );
371
371
} catch (Exception o_O ) {
372
372
throw new RuntimeException (o_O );
373
373
}
0 commit comments