Browse Source

Polishing

pull/26393/head
Sam Brannen 4 years ago
parent
commit
1bbc5648f9
  1. 1
      spring-core/src/main/java/org/springframework/aot/hint/ProxyHintsPredicates.java
  2. 5
      spring-core/src/main/java/org/springframework/aot/hint/ReflectionHintsPredicates.java
  3. 1
      spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java
  4. 1
      spring-core/src/main/java/org/springframework/aot/hint/ResourceHintsPredicates.java
  5. 5
      spring-core/src/main/java/org/springframework/aot/hint/RuntimeHintsPredicates.java
  6. 1
      spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java
  7. 27
      spring-core/src/test/java/org/springframework/aot/hint/ReflectionTypeReferenceTests.java

1
spring-core/src/main/java/org/springframework/aot/hint/ProxyHintsPredicates.java

@ -24,6 +24,7 @@ import org.springframework.util.Assert; @@ -24,6 +24,7 @@ import org.springframework.util.Assert;
/**
* Generator of {@link ProxyHints} predicates, testing whether the given hints
* match the expected behavior for proxies.
*
* @author Brian Clozel
* @since 6.0
*/

5
spring-core/src/main/java/org/springframework/aot/hint/ReflectionHintsPredicates.java

@ -34,6 +34,7 @@ import org.springframework.util.ReflectionUtils; @@ -34,6 +34,7 @@ import org.springframework.util.ReflectionUtils;
/**
* Generator of {@link ReflectionHints} predicates, testing whether the given hints
* match the expected behavior for reflection.
*
* @author Brian Clozel
* @since 6.0
*/
@ -265,6 +266,7 @@ public class ReflectionHintsPredicates { @@ -265,6 +266,7 @@ public class ReflectionHintsPredicates {
super(constructor);
}
@Override
MemberCategory[] getPublicMemberCategories() {
if (this.executableMode == ExecutableMode.INTROSPECT) {
return new MemberCategory[] {MemberCategory.INTROSPECT_PUBLIC_CONSTRUCTORS,
@ -273,6 +275,7 @@ public class ReflectionHintsPredicates { @@ -273,6 +275,7 @@ public class ReflectionHintsPredicates {
return new MemberCategory[] {MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS};
}
@Override
MemberCategory[] getDeclaredMemberCategories() {
if (this.executableMode == ExecutableMode.INTROSPECT) {
return new MemberCategory[] {MemberCategory.INTROSPECT_DECLARED_CONSTRUCTORS,
@ -299,6 +302,7 @@ public class ReflectionHintsPredicates { @@ -299,6 +302,7 @@ public class ReflectionHintsPredicates {
super(method);
}
@Override
MemberCategory[] getPublicMemberCategories() {
if (this.executableMode == ExecutableMode.INTROSPECT) {
return new MemberCategory[] {MemberCategory.INTROSPECT_PUBLIC_METHODS,
@ -307,6 +311,7 @@ public class ReflectionHintsPredicates { @@ -307,6 +311,7 @@ public class ReflectionHintsPredicates {
return new MemberCategory[] {MemberCategory.INVOKE_PUBLIC_METHODS};
}
@Override
MemberCategory[] getDeclaredMemberCategories() {
if (this.executableMode == ExecutableMode.INTROSPECT) {

1
spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java

@ -22,6 +22,7 @@ import org.springframework.lang.Nullable; @@ -22,6 +22,7 @@ import org.springframework.lang.Nullable;
* A {@link TypeReference} based on a {@link Class}.
*
* @author Stephane Nicoll
* @since 6.0
*/
final class ReflectionTypeReference extends AbstractTypeReference {

1
spring-core/src/main/java/org/springframework/aot/hint/ResourceHintsPredicates.java

@ -25,6 +25,7 @@ import org.springframework.util.ConcurrentLruCache; @@ -25,6 +25,7 @@ import org.springframework.util.ConcurrentLruCache;
/**
* Generator of {@link ResourceHints} predicates, testing whether the given hints
* match the expected behavior for resources.
*
* @author Brian Clozel
* @since 6.0
*/

5
spring-core/src/main/java/org/springframework/aot/hint/RuntimeHintsPredicates.java

@ -18,7 +18,8 @@ package org.springframework.aot.hint; @@ -18,7 +18,8 @@ package org.springframework.aot.hint;
/**
* Static generator of predicates that test whether the given {@link RuntimeHints}
* instance matches the expected behavior for reflection, resource or proxy generation.
* instance matches the expected behavior for reflection, resource, or proxy generation.
*
* <p>This utility class can be used by {@link RuntimeHintsRegistrar} to conditionally
* register hints depending on what's present already. This can also be used as a
* testing utility for checking proper registration of hints:
@ -26,6 +27,7 @@ package org.springframework.aot.hint; @@ -26,6 +27,7 @@ package org.springframework.aot.hint;
* Predicate&lt;RuntimeHints&gt; predicate = RuntimeHintsPredicates.reflection().onMethod(MyClass.class, "someMethod").invoke();
* assertThat(predicate).accepts(runtimeHints);
* </pre>
*
* @author Brian Clozel
* @since 6.0
*/
@ -39,7 +41,6 @@ public abstract class RuntimeHintsPredicates { @@ -39,7 +41,6 @@ public abstract class RuntimeHintsPredicates {
private RuntimeHintsPredicates() {
}
/**

1
spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java

@ -27,6 +27,7 @@ import org.springframework.util.Assert; @@ -27,6 +27,7 @@ import org.springframework.util.Assert;
* A {@link TypeReference} based on fully qualified name.
*
* @author Stephane Nicoll
* @since 6.0
*/
final class SimpleTypeReference extends AbstractTypeReference {

27
spring-core/src/test/java/org/springframework/aot/hint/ReflectionTypeReferenceTests.java

@ -23,6 +23,7 @@ import org.junit.jupiter.params.provider.Arguments; @@ -23,6 +23,7 @@ import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
/**
* Tests for {@link ReflectionTypeReference}.
@ -34,28 +35,24 @@ class ReflectionTypeReferenceTests { @@ -34,28 +35,24 @@ class ReflectionTypeReferenceTests {
@ParameterizedTest
@MethodSource("reflectionTargetNames")
void typeReferenceFromClasHasSuitableReflectionTargetName(TypeReference typeReference, String binaryName) {
assertThat(typeReference.getName()).isEqualTo(binaryName);
void typeReferenceFromClassHasSuitableReflectionTargetName(Class<?> clazz, String binaryName) {
assertThat(ReflectionTypeReference.of(clazz).getName()).isEqualTo(binaryName);
}
static Stream<Arguments> reflectionTargetNames() {
return Stream.of(
Arguments.of(ReflectionTypeReference.of(int.class), "int"),
Arguments.of(ReflectionTypeReference.of(int[].class), "int[]"),
Arguments.of(ReflectionTypeReference.of(Integer[].class), "java.lang.Integer[]"),
Arguments.of(ReflectionTypeReference.of(Object[].class), "java.lang.Object[]"),
Arguments.of(ReflectionTypeReference.of(StaticInner.class),
"org.springframework.aot.hint.ReflectionTypeReferenceTests$StaticInner"),
Arguments.of(ReflectionTypeReference.of(StaticInner[].class),
"org.springframework.aot.hint.ReflectionTypeReferenceTests$StaticInner[]"),
Arguments.of(ReflectionTypeReference.of(Inner.class),
"org.springframework.aot.hint.ReflectionTypeReferenceTests$Inner"),
Arguments.of(ReflectionTypeReference.of(Inner[].class),
"org.springframework.aot.hint.ReflectionTypeReferenceTests$Inner[]")
arguments(int.class, "int"),
arguments(int[].class, "int[]"),
arguments(Integer[].class, "java.lang.Integer[]"),
arguments(Object[].class, "java.lang.Object[]"),
arguments(StaticNested.class, "org.springframework.aot.hint.ReflectionTypeReferenceTests$StaticNested"),
arguments(StaticNested[].class, "org.springframework.aot.hint.ReflectionTypeReferenceTests$StaticNested[]"),
arguments(Inner.class, "org.springframework.aot.hint.ReflectionTypeReferenceTests$Inner"),
arguments(Inner[].class, "org.springframework.aot.hint.ReflectionTypeReferenceTests$Inner[]")
);
}
static class StaticInner {
static class StaticNested {
}
class Inner {

Loading…
Cancel
Save