Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Aug 13, 2024
1 parent eff1ca9 commit b5377ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -121,16 +121,16 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
implements ConfigurableListableBeanFactory, BeanDefinitionRegistry, Serializable {

@Nullable
private static Class<?> javaxInjectProviderClass;
private static Class<?> jakartaInjectProviderClass;

static {
try {
javaxInjectProviderClass =
jakartaInjectProviderClass =
ClassUtils.forName("jakarta.inject.Provider", DefaultListableBeanFactory.class.getClassLoader());
}
catch (ClassNotFoundException ex) {
// JSR-330 API not available - Provider interface simply not supported then.
javaxInjectProviderClass = null;
jakartaInjectProviderClass = null;
}
}

Expand Down Expand Up @@ -1327,7 +1327,7 @@ else if (ObjectFactory.class == descriptor.getDependencyType() ||
ObjectProvider.class == descriptor.getDependencyType()) {
return new DependencyObjectProvider(descriptor, requestingBeanName);
}
else if (javaxInjectProviderClass == descriptor.getDependencyType()) {
else if (jakartaInjectProviderClass == descriptor.getDependencyType()) {
return new Jsr330Factory().createDependencyProvider(descriptor, requestingBeanName);
}
else {
Expand Down Expand Up @@ -1757,7 +1757,7 @@ else if (candidatePriority < highestPriority) {
* Return whether the bean definition for the given bean name has been
* marked as a primary bean.
* @param beanName the name of the bean
* @param beanInstance the corresponding bean instance (can be null)
* @param beanInstance the corresponding bean instance (can be {@code null})
* @return whether the given bean qualifies as primary
*/
protected boolean isPrimary(String beanName, Object beanInstance) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -40,7 +40,7 @@

/**
* Register the necessary reflection hints so that the specified type can be
* bound at runtime. Fields, constructors, properties and record components
* bound at runtime. Fields, constructors, properties, and record components
* are registered, except for a set of types like those in the {@code java.}
* package where just the type is registered. Types are discovered transitively
* on properties and record components, and generic types are registered as well.
Expand All @@ -54,8 +54,9 @@ public class BindingReflectionHintsRegistrar {

private static final String JACKSON_ANNOTATION = "com.fasterxml.jackson.annotation.JacksonAnnotation";

private static final boolean jacksonAnnotationPresent = ClassUtils.isPresent(JACKSON_ANNOTATION,
BindingReflectionHintsRegistrar.class.getClassLoader());
private static final boolean jacksonAnnotationPresent =
ClassUtils.isPresent(JACKSON_ANNOTATION, BindingReflectionHintsRegistrar.class.getClassLoader());


/**
* Register the necessary reflection hints to bind the specified types.
Expand Down Expand Up @@ -94,8 +95,7 @@ private void registerReflectionHints(ReflectionHints hints, Set<Type> seen, Type
registerRecordHints(hints, seen, recordComponent.getAccessor());
}
}
typeHint.withMembers(
MemberCategory.DECLARED_FIELDS,
typeHint.withMembers(MemberCategory.DECLARED_FIELDS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
for (Method method : clazz.getMethods()) {
String methodName = method.getName();
Expand Down Expand Up @@ -132,8 +132,7 @@ private void registerRecordHints(ReflectionHints hints, Set<Type> seen, Method m
}

private void registerPropertyHints(ReflectionHints hints, Set<Type> seen, @Nullable Method method, int parameterIndex) {
if (method != null && method.getDeclaringClass() != Object.class &&
method.getDeclaringClass() != Enum.class) {
if (method != null && method.getDeclaringClass() != Object.class && method.getDeclaringClass() != Enum.class) {
hints.registerMethod(method, ExecutableMode.INVOKE);
MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex);
Type methodParameterType = methodParameter.getGenericParameterType();
Expand Down Expand Up @@ -191,13 +190,13 @@ private void forEachJacksonAnnotation(AnnotatedElement element, Consumer<MergedA
.from(element, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY)
.stream(JACKSON_ANNOTATION)
.filter(MergedAnnotation::isMetaPresent)
.forEach(action::accept);
.forEach(action);
}

private void registerHintsForClassAttributes(ReflectionHints hints, MergedAnnotation<Annotation> annotation) {
annotation.getRoot().asMap().forEach((key,value) -> {
annotation.getRoot().asMap().forEach((attributeName, value) -> {
if (value instanceof Class<?> classValue && value != Void.class) {
if (key.equals("builder")) {
if (attributeName.equals("builder")) {
hints.registerType(classValue, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS);
}
Expand All @@ -208,6 +207,7 @@ private void registerHintsForClassAttributes(ReflectionHints hints, MergedAnnota
});
}


/**
* Inner class to avoid a hard dependency on Kotlin at runtime.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -393,7 +393,7 @@ private String toHeaderValue() {
}

private void appendDirective(StringBuilder builder, String value) {
if (builder.length() > 0) {
if (!builder.isEmpty()) {
builder.append(", ");
}
builder.append(value);
Expand Down

0 comments on commit b5377ee

Please sign in to comment.