Polishing
This commit is contained in:
@@ -80,6 +80,7 @@ public class DefaultGenerationContext implements GenerationContext {
|
||||
*/
|
||||
DefaultGenerationContext(GeneratedClasses generatedClasses,
|
||||
GeneratedFiles generatedFiles, RuntimeHints runtimeHints) {
|
||||
|
||||
Assert.notNull(generatedClasses, "'generatedClasses' must not be null");
|
||||
Assert.notNull(generatedFiles, "'generatedFiles' must not be null");
|
||||
Assert.notNull(runtimeHints, "'runtimeHints' must not be null");
|
||||
@@ -90,8 +91,7 @@ public class DefaultGenerationContext implements GenerationContext {
|
||||
}
|
||||
|
||||
private DefaultGenerationContext(DefaultGenerationContext existing, String name) {
|
||||
int sequence = existing.sequenceGenerator
|
||||
.computeIfAbsent(name, key -> new AtomicInteger()).getAndIncrement();
|
||||
int sequence = existing.sequenceGenerator.computeIfAbsent(name, key -> new AtomicInteger()).getAndIncrement();
|
||||
String featureName = (sequence > 0 ? name + sequence : name);
|
||||
this.sequenceGenerator = existing.sequenceGenerator;
|
||||
this.generatedClasses = existing.generatedClasses.withFeatureNamePrefix(featureName);
|
||||
@@ -99,6 +99,7 @@ public class DefaultGenerationContext implements GenerationContext {
|
||||
this.runtimeHints = existing.runtimeHints;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GeneratedClasses getGeneratedClasses() {
|
||||
return this.generatedClasses;
|
||||
|
||||
@@ -133,6 +133,7 @@ public class ReflectionHints {
|
||||
*/
|
||||
public ReflectionHints registerTypeIfPresent(@Nullable ClassLoader classLoader,
|
||||
String typeName, Consumer<TypeHint.Builder> typeHint) {
|
||||
|
||||
if (ClassUtils.isPresent(typeName, classLoader)) {
|
||||
registerType(TypeReference.of(typeName), typeHint);
|
||||
}
|
||||
@@ -149,6 +150,7 @@ public class ReflectionHints {
|
||||
*/
|
||||
public ReflectionHints registerTypeIfPresent(@Nullable ClassLoader classLoader,
|
||||
String typeName, MemberCategory... memberCategories) {
|
||||
|
||||
return registerTypeIfPresent(classLoader, typeName, TypeHint.builtWith(memberCategories));
|
||||
}
|
||||
|
||||
@@ -208,7 +210,6 @@ public class ReflectionHints {
|
||||
* @deprecated in favor of {@link #registerConstructor(Constructor, ExecutableMode)}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public ReflectionHints registerConstructor(Constructor<?> constructor, Consumer<ExecutableHint.Builder> constructorHint) {
|
||||
return registerType(TypeReference.of(constructor.getDeclaringClass()),
|
||||
typeHint -> typeHint.withConstructor(mapParameters(constructor), constructorHint));
|
||||
@@ -246,15 +247,14 @@ public class ReflectionHints {
|
||||
* @deprecated in favor of {@link #registerMethod(Method, ExecutableMode)}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
public ReflectionHints registerMethod(Method method, Consumer<ExecutableHint.Builder> methodHint) {
|
||||
return registerType(TypeReference.of(method.getDeclaringClass()),
|
||||
typeHint -> typeHint.withMethod(method.getName(), mapParameters(method), methodHint));
|
||||
}
|
||||
|
||||
private List<TypeReference> mapParameters(Executable executable) {
|
||||
return Arrays.stream(executable.getParameterTypes()).map(TypeReference::of)
|
||||
.collect(Collectors.toList());
|
||||
return Arrays.stream(executable.getParameterTypes()).map(TypeReference::of).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user