Skip to content

Commit 0fe04e3

Browse files
committed
Polishing.
Refine control flow. See #2704 Original pull request: #2705.
1 parent 529f88c commit 0fe04e3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/org/springframework/data/aot/ManagedTypesRegistrationAotContribution.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ void generateInstanceFactory(Builder method) {
169169

170170
ParameterizedTypeName targetTypeName = ParameterizedTypeName.get(InstanceSupplier.class, source.getBeanClass());
171171

172+
method.addJavadoc("Get the bean instance for '$L'.", source.getBeanName());
172173
method.addModifiers(Modifier.PRIVATE, Modifier.STATIC);
173174
method.returns(targetTypeName);
174175

@@ -177,14 +178,15 @@ void generateInstanceFactory(Builder method) {
177178
if (sourceTypes.isEmpty()) {
178179
builder.addStatement("$T types = $T.emptyList()", LIST_OF_ANY, Collections.class);
179180
} else {
181+
182+
TypeName variableTypeName;
180183
if (allSourceTypesVisible) {
181-
builder.addStatement("$T types = $T.of($L)", LIST_OF_ANY, List.class,
182-
toCodeBlock(sourceTypes, allSourceTypesVisible));
184+
variableTypeName = LIST_OF_ANY;
183185
} else {
184-
TypeName listOfString = ParameterizedTypeName.get(ClassName.get(List.class), ClassName.get(String.class));
185-
builder.addStatement("$T types = $T.of($L)", listOfString, List.class,
186-
toCodeBlock(sourceTypes, allSourceTypesVisible));
186+
variableTypeName = ParameterizedTypeName.get(ClassName.get(List.class), ClassName.get(String.class));
187187
}
188+
builder.addStatement("$T types = $T.of($L)", variableTypeName, List.class,
189+
toCodeBlock(sourceTypes, allSourceTypesVisible));
188190
}
189191

190192
if (allSourceTypesVisible) {

0 commit comments

Comments
 (0)