Skip to content

Commit 2a8402c

Browse files
mp911dechristophstrobl
authored andcommitted
Polishing.
Use constants where possible. Original Pull Request: #3083
1 parent a37a700 commit 2a8402c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/java/org/springframework/data/repository/config/AnnotationRepositoryConfigurationSource.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public class AnnotationRepositoryConfigurationSource extends RepositoryConfigura
6666
private static final String CONSIDER_NESTED_REPOSITORIES = "considerNestedRepositories";
6767
private static final String BOOTSTRAP_MODE = "bootstrapMode";
6868
private static final String BEAN_NAME_GENERATOR = "nameGenerator";
69+
private static final String INCLUDE_FILTERS = "includeFilters";
70+
private static final String EXCLUDE_FILTERS = "excludeFilters";
6971

7072
private final AnnotationMetadata configMetadata;
7173
private final AnnotationMetadata enableAnnotationMetadata;
@@ -175,12 +177,12 @@ public Object getSource() {
175177

176178
@Override
177179
protected Iterable<TypeFilter> getIncludeFilters() {
178-
return parseFilters("includeFilters");
180+
return parseFilters(INCLUDE_FILTERS);
179181
}
180182

181183
@Override
182184
public Streamable<TypeFilter> getExcludeFilters() {
183-
return parseFilters("excludeFilters");
185+
return parseFilters(EXCLUDE_FILTERS);
184186
}
185187

186188
@Override
@@ -304,7 +306,7 @@ private Optional<String> getNullDefaultedAttribute(String attributeName) {
304306
*/
305307
private static boolean hasExplicitFilters(AnnotationAttributes attributes) {
306308

307-
return Stream.of("includeFilters", "excludeFilters") //
309+
return Stream.of(INCLUDE_FILTERS, EXCLUDE_FILTERS) //
308310
.anyMatch(it -> attributes.getAnnotationArray(it).length > 0);
309311
}
310312

@@ -333,13 +335,15 @@ private static BeanNameGenerator configuredOrDefaultBeanNameGenerator(Annotation
333335
* customized.
334336
*
335337
* @param generator can be {@literal null}.
336-
* @return
338+
* @return the configured {@link BeanNameGenerator} if it is not
339+
* {@link ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR} or {@link AnnotationBeanNameGenerator}
340+
* otherwise.
337341
* @since 2.2
338342
*/
339343
private static BeanNameGenerator defaultBeanNameGenerator(@Nullable BeanNameGenerator generator) {
340344

341345
return generator == null || ConfigurationClassPostProcessor.IMPORT_BEAN_NAME_GENERATOR.equals(generator) //
342-
? new AnnotationBeanNameGenerator() //
346+
? AnnotationBeanNameGenerator.INSTANCE //
343347
: generator;
344348
}
345349

0 commit comments

Comments
 (0)