Polishing
This commit is contained in:
@@ -55,7 +55,7 @@ public final class ExecutableHint extends MemberHint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a builder with the name and parameters types of a method.
|
||||
* Initialize a builder with the name and parameter types of a method.
|
||||
* @param name the name of the method
|
||||
* @param parameterTypes the parameter types of the method
|
||||
* @return a builder
|
||||
@@ -74,7 +74,7 @@ public final class ExecutableHint extends MemberHint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@linkplain ExecutableMode mode} that apply to this hint.
|
||||
* Return the {@linkplain ExecutableMode mode} that applies to this hint.
|
||||
* @return the mode
|
||||
*/
|
||||
public ExecutableMode getMode() {
|
||||
@@ -116,7 +116,7 @@ public final class ExecutableHint extends MemberHint {
|
||||
*/
|
||||
public Builder withMode(ExecutableMode mode) {
|
||||
Assert.notNull(mode, "'mode' must not be null");
|
||||
if ((this.mode == null || !this.mode.includes(mode))) {
|
||||
if ((this.mode == null) || !this.mode.includes(mode)) {
|
||||
this.mode = mode;
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A hint that describes the need of reflection on a {@link Field}.
|
||||
* A hint that describes the need for reflection on a {@link Field}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 6.0
|
||||
@@ -52,7 +52,7 @@ public final class FieldHint extends MemberHint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@linkplain FieldMode mode} that apply to this hint.
|
||||
* Return the {@linkplain FieldMode mode} that applies to this hint.
|
||||
* @return the mode
|
||||
*/
|
||||
public FieldMode getMode() {
|
||||
@@ -60,7 +60,7 @@ public final class FieldHint extends MemberHint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether if using {@code Unsafe} on the field should be allowed.
|
||||
* Return whether using {@code Unsafe} on the field should be allowed.
|
||||
* @return {@code true} to allow unsafe access
|
||||
*/
|
||||
public boolean isAllowUnsafeAccess() {
|
||||
@@ -123,7 +123,7 @@ public final class FieldHint extends MemberHint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify if using {@code Unsafe} on the field should be allowed.
|
||||
* Specify whether using {@code Unsafe} on the field should be allowed.
|
||||
* @param allowUnsafeAccess {@code true} to allow unsafe access
|
||||
* @return {@code this}, to facilitate method chaining
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,7 @@ class ReflectionHintsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerTypeIfPresentRegisterExistingClass() {
|
||||
void registerTypeIfPresentRegistersExistingClass() {
|
||||
this.reflectionHints.registerTypeIfPresent(null, String.class.getName(),
|
||||
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS));
|
||||
assertThat(this.reflectionHints.typeHints()).singleElement().satisfies(
|
||||
@@ -56,7 +56,7 @@ class ReflectionHintsTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void registerTypeIfPresentIgnoreMissingClass() {
|
||||
void registerTypeIfPresentIgnoresMissingClass() {
|
||||
Consumer<TypeHint.Builder> hintBuilder = mock(Consumer.class);
|
||||
this.reflectionHints.registerTypeIfPresent(null, "com.example.DoesNotExist", hintBuilder);
|
||||
assertThat(this.reflectionHints.typeHints()).isEmpty();
|
||||
@@ -84,7 +84,7 @@ class ReflectionHintsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerTypeReuseBuilder() {
|
||||
void registerTypeReusesBuilder() {
|
||||
this.reflectionHints.registerType(TypeReference.of(String.class),
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
Field field = ReflectionUtils.findField(String.class, "value");
|
||||
@@ -105,7 +105,7 @@ class ReflectionHintsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerClassWitCustomizer() {
|
||||
void registerClassWithCustomizer() {
|
||||
this.reflectionHints.registerType(Integer.class,
|
||||
typeHint -> typeHint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
assertThat(this.reflectionHints.typeHints()).singleElement().satisfies(
|
||||
@@ -113,16 +113,13 @@ class ReflectionHintsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerTypesApplyTheSameHints() {
|
||||
void registerTypesAppliesTheSameHints() {
|
||||
this.reflectionHints.registerTypes(TypeReference.listOf(Integer.class, String.class, Double.class),
|
||||
TypeHint.builtWith(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
assertThat(this.reflectionHints.typeHints())
|
||||
.anySatisfy(
|
||||
typeWithMemberCategories(Integer.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.anySatisfy(
|
||||
typeWithMemberCategories(String.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.anySatisfy(
|
||||
typeWithMemberCategories(Double.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.anySatisfy(typeWithMemberCategories(Integer.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.anySatisfy(typeWithMemberCategories(String.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.anySatisfy(typeWithMemberCategories(Double.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.hasSize(3);
|
||||
}
|
||||
|
||||
@@ -286,8 +283,7 @@ class ReflectionHintsTests {
|
||||
void registerMethodWithCustomizerAppliesCustomization() {
|
||||
Method method = ReflectionUtils.findMethod(TestType.class, "setName", String.class);
|
||||
assertThat(method).isNotNull();
|
||||
this.reflectionHints.registerMethod(method, methodHint ->
|
||||
methodHint.withMode(ExecutableMode.INTROSPECT));
|
||||
this.reflectionHints.registerMethod(method, methodHint -> methodHint.withMode(ExecutableMode.INTROSPECT));
|
||||
assertTestTypeMethodHints(methodHint -> {
|
||||
assertThat(methodHint.getName()).isEqualTo("setName");
|
||||
assertThat(methodHint.getParameterTypes()).containsOnly(TypeReference.of(String.class));
|
||||
|
||||
@@ -220,8 +220,8 @@ public class TestContextAotGenerator {
|
||||
new AotTestMappingsCodeGenerator(initializerClassMappings, generatedClasses);
|
||||
generationContext.writeGeneratedContent();
|
||||
String className = codeGenerator.getGeneratedClass().getName().reflectionName();
|
||||
this.runtimeHints.reflection().registerType(TypeReference.of(className),
|
||||
builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||
this.runtimeHints.reflection()
|
||||
.registerType(TypeReference.of(className), MemberCategory.INVOKE_PUBLIC_METHODS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user