Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,15 +47,15 @@ import org.springframework.javapoet.CodeBlock;
|
||||
abstract class BeanDefinitionPropertyValueCodeGeneratorDelegates {
|
||||
|
||||
/**
|
||||
* Return the {@link Delegate} implementations for common bean definition
|
||||
* property value types. These are:
|
||||
* A list of {@link Delegate} implementations for the following common bean
|
||||
* definition property value types.
|
||||
* <ul>
|
||||
* <li>{@link ManagedList},</li>
|
||||
* <li>{@link ManagedSet},</li>
|
||||
* <li>{@link ManagedMap},</li>
|
||||
* <li>{@link LinkedHashMap},</li>
|
||||
* <li>{@link BeanReference},</li>
|
||||
* <li>{@link TypedStringValue}.</li>
|
||||
* <li>{@link ManagedList}</li>
|
||||
* <li>{@link ManagedSet}</li>
|
||||
* <li>{@link ManagedMap}</li>
|
||||
* <li>{@link LinkedHashMap}</li>
|
||||
* <li>{@link BeanReference}</li>
|
||||
* <li>{@link TypedStringValue}</li>
|
||||
* </ul>
|
||||
* When combined with {@linkplain ValueCodeGeneratorDelegates#INSTANCES the
|
||||
* delegates for common value types}, this should be added first as they have
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.javapoet.AnnotationSpec;
|
||||
@@ -118,9 +117,7 @@ class CodeWarnings {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringJoiner(", ", CodeWarnings.class.getSimpleName(), "")
|
||||
.add(this.warnings.toString())
|
||||
.toString();
|
||||
return CodeWarnings.class.getSimpleName() + this.warnings;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,14 +43,10 @@ class CodeWarningsTests {
|
||||
private static final TestCompiler TEST_COMPILER = TestCompiler.forSystem()
|
||||
.withCompilerOptions("-Xlint:all", "-Werror");
|
||||
|
||||
private final CodeWarnings codeWarnings;
|
||||
private final CodeWarnings codeWarnings = new CodeWarnings();
|
||||
|
||||
private final TestGenerationContext generationContext;
|
||||
private final TestGenerationContext generationContext = new TestGenerationContext();
|
||||
|
||||
CodeWarningsTests() {
|
||||
this.codeWarnings = new CodeWarnings();
|
||||
this.generationContext = new TestGenerationContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerNoWarningDoesNotIncludeAnnotation() {
|
||||
@@ -67,8 +63,7 @@ class CodeWarningsTests {
|
||||
compile(method -> {
|
||||
this.codeWarnings.suppress(method);
|
||||
method.addStatement("$T bean = new $T()", DeprecatedBean.class, DeprecatedBean.class);
|
||||
}, compiled -> assertThat(compiled.getSourceFile())
|
||||
.contains("@SuppressWarnings(\"deprecation\")"));
|
||||
}, compiled -> assertThat(compiled.getSourceFile()).contains("@SuppressWarnings(\"deprecation\")"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,26 +75,25 @@ class CodeWarningsTests {
|
||||
this.codeWarnings.suppress(method);
|
||||
method.addStatement("$T bean = new $T()", DeprecatedBean.class, DeprecatedBean.class);
|
||||
method.addStatement("$T another = new $T()", DeprecatedForRemovalBean.class, DeprecatedForRemovalBean.class);
|
||||
}, compiled -> assertThat(compiled.getSourceFile())
|
||||
.contains("@SuppressWarnings({ \"deprecation\", \"removal\" })"));
|
||||
}, compiled -> assertThat(compiled.getSourceFile()).contains("@SuppressWarnings({ \"deprecation\", \"removal\" })"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void detectDeprecationOnAnnotatedElementWithDeprecated() {
|
||||
this.codeWarnings.detectDeprecation(DeprecatedBean.class);
|
||||
assertThat(this.codeWarnings.getWarnings()).containsExactly("deprecation");
|
||||
assertThat(this.codeWarnings.getWarnings()).containsOnly("deprecation");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void detectDeprecationOnAnnotatedElementWithDeprecatedForRemoval() {
|
||||
this.codeWarnings.detectDeprecation(DeprecatedForRemovalBean.class);
|
||||
assertThat(this.codeWarnings.getWarnings()).containsExactly("removal");
|
||||
assertThat(this.codeWarnings.getWarnings()).containsOnly("removal");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toStringIncludeWarnings() {
|
||||
void toStringIncludesWarnings() {
|
||||
this.codeWarnings.register("deprecation");
|
||||
this.codeWarnings.register("rawtypes");
|
||||
assertThat(this.codeWarnings).hasToString("CodeWarnings[deprecation, rawtypes]");
|
||||
|
||||
Reference in New Issue
Block a user