Skip to content

Commit feb6a5f

Browse files
committed
Polishing
1 parent a228eb8 commit feb6a5f

File tree

12 files changed

+75
-124
lines changed

12 files changed

+75
-124
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,9 +29,11 @@
2929

3030
/**
3131
* A simple descriptor for an injection point, pointing to a method/constructor
32-
* parameter or a field. Exposed by {@link UnsatisfiedDependencyException}.
33-
* Also available as an argument for factory methods, reacting to the
34-
* requesting injection point for building a customized bean instance.
32+
* parameter or a field.
33+
*
34+
* <p>Exposed by {@link UnsatisfiedDependencyException}. Also available as an
35+
* argument for factory methods, reacting to the requesting injection point
36+
* for building a customized bean instance.
3537
*
3638
* @author Juergen Hoeller
3739
* @since 4.3

spring-beans/src/main/java/org/springframework/beans/factory/aot/DefaultBeanRegistrationCodeFragments.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class DefaultBeanRegistrationCodeFragments implements BeanRegistrationCodeFragme
6464
private final Supplier<InstantiationDescriptor> instantiationDescriptor;
6565

6666

67-
DefaultBeanRegistrationCodeFragments(BeanRegistrationsCode beanRegistrationsCode,
68-
RegisteredBean registeredBean,
67+
DefaultBeanRegistrationCodeFragments(
68+
BeanRegistrationsCode beanRegistrationsCode, RegisteredBean registeredBean,
6969
BeanDefinitionMethodGeneratorFactory beanDefinitionMethodGeneratorFactory) {
7070

7171
this.beanRegistrationsCode = beanRegistrationsCode;

spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -148,10 +148,10 @@ public DependencyDescriptor(DependencyDescriptor original) {
148148
this.parameterTypes = original.parameterTypes;
149149
this.parameterIndex = original.parameterIndex;
150150
this.fieldName = original.fieldName;
151-
this.containingClass = original.containingClass;
152151
this.required = original.required;
153152
this.eager = original.eager;
154153
this.nestingLevel = original.nestingLevel;
154+
this.containingClass = original.containingClass;
155155
}
156156

157157

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ private <T> T resolveBean(ResolvableType requiredType, @Nullable Object[] args,
488488
return namedBean.getBeanInstance();
489489
}
490490
BeanFactory parent = getParentBeanFactory();
491-
if (parent instanceof DefaultListableBeanFactory dlfb) {
492-
return dlfb.resolveBean(requiredType, args, nonUniqueAsNull);
491+
if (parent instanceof DefaultListableBeanFactory dlbf) {
492+
return dlbf.resolveBean(requiredType, args, nonUniqueAsNull);
493493
}
494494
else if (parent != null) {
495495
ObjectProvider<T> parentProvider = parent.getBeanProvider(requiredType);

spring-core/src/main/java/org/springframework/aot/generate/AccessControl.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,11 +45,13 @@ public final class AccessControl {
4545

4646
private final Visibility visibility;
4747

48+
4849
AccessControl(Class<?> target, Visibility visibility) {
4950
this.target = target;
5051
this.visibility = visibility;
5152
}
5253

54+
5355
/**
5456
* Create an {@link AccessControl} for the given member. This considers the
5557
* member modifier, parameter types, return types and any enclosing classes.
@@ -68,8 +70,7 @@ public static AccessControl forMember(Member member) {
6870
* @return the {@link AccessControl} for the type
6971
*/
7072
public static AccessControl forResolvableType(ResolvableType resolvableType) {
71-
return new AccessControl(resolvableType.toClass(),
72-
Visibility.forResolvableType(resolvableType));
73+
return new AccessControl(resolvableType.toClass(), Visibility.forResolvableType(resolvableType));
7374
}
7475

7576
/**
@@ -87,8 +88,8 @@ public static AccessControl forClass(Class<?> type) {
8788
* @return the lowest {@link AccessControl} from the candidates
8889
*/
8990
public static AccessControl lowest(AccessControl... candidates) {
90-
int index = Visibility.lowestIndex(Arrays.stream(candidates)
91-
.map(AccessControl::getVisibility).toArray(Visibility[]::new));
91+
int index = Visibility.lowestIndex(
92+
Arrays.stream(candidates).map(AccessControl::getVisibility).toArray(Visibility[]::new));
9293
return candidates[index];
9394
}
9495

@@ -125,6 +126,7 @@ public boolean isAccessibleFrom(ClassName type) {
125126
return this.target.getPackageName().equals(type.packageName());
126127
}
127128

129+
128130
/**
129131
* Access visibility types as determined by the <a href=
130132
* "https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html">modifiers</a>
@@ -270,6 +272,6 @@ static int lowestIndex(Visibility... candidates) {
270272
}
271273
return index;
272274
}
273-
274275
}
276+
275277
}

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

+11-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,21 +28,22 @@
2828
* @author Brian Clozel
2929
* @since 6.0
3030
*/
31-
public class JavaSerializationHint implements ConditionalHint {
31+
public final class JavaSerializationHint implements ConditionalHint {
3232

3333
private final TypeReference type;
3434

3535
@Nullable
3636
private final TypeReference reachableType;
3737

38+
3839
JavaSerializationHint(Builder builder) {
3940
this.type = builder.type;
4041
this.reachableType = builder.reachableType;
4142
}
4243

44+
4345
/**
44-
* Return the {@link TypeReference type} that needs to be serialized using
45-
* Java serialization at runtime.
46+
* Return the {@link TypeReference type} that needs to be serialized using Java serialization at runtime.
4647
* @return a {@link Serializable} type
4748
*/
4849
public TypeReference getType() {
@@ -56,16 +57,9 @@ public TypeReference getReachableType() {
5657
}
5758

5859
@Override
59-
public boolean equals(@Nullable Object o) {
60-
if (this == o) {
61-
return true;
62-
}
63-
if (o == null || getClass() != o.getClass()) {
64-
return false;
65-
}
66-
JavaSerializationHint that = (JavaSerializationHint) o;
67-
return this.type.equals(that.type)
68-
&& Objects.equals(this.reachableType, that.reachableType);
60+
public boolean equals(@Nullable Object other) {
61+
return (this == other || (other instanceof JavaSerializationHint that &&
62+
this.type.equals(that.type) && Objects.equals(this.reachableType, that.reachableType)));
6963
}
7064

7165
@Override
@@ -84,16 +78,13 @@ public static class Builder {
8478
@Nullable
8579
private TypeReference reachableType;
8680

87-
8881
Builder(TypeReference type) {
8982
this.type = type;
9083
}
9184

9285
/**
93-
* Make this hint conditional on the fact that the specified type
94-
* can be resolved.
95-
* @param reachableType the type that should be reachable for this
96-
* hint to apply
86+
* Make this hint conditional on the fact that the specified type can be resolved.
87+
* @param reachableType the type that should be reachable for this hint to apply
9788
* @return {@code this}, to facilitate method chaining
9889
*/
9990
public Builder onReachableType(TypeReference reachableType) {
@@ -108,6 +99,6 @@ public Builder onReachableType(TypeReference reachableType) {
10899
JavaSerializationHint build() {
109100
return new JavaSerializationHint(this);
110101
}
111-
112102
}
103+
113104
}

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

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -62,6 +62,7 @@ public static Builder of(Class<?>... proxiedInterfaces) {
6262
return new Builder().proxiedInterfaces(proxiedInterfaces);
6363
}
6464

65+
6566
/**
6667
* Return the interfaces to be proxied.
6768
* @return the interfaces that the proxy should implement
@@ -77,16 +78,10 @@ public TypeReference getReachableType() {
7778
}
7879

7980
@Override
80-
public boolean equals(@Nullable Object o) {
81-
if (this == o) {
82-
return true;
83-
}
84-
if (o == null || getClass() != o.getClass()) {
85-
return false;
86-
}
87-
JdkProxyHint that = (JdkProxyHint) o;
88-
return this.proxiedInterfaces.equals(that.proxiedInterfaces)
89-
&& Objects.equals(this.reachableType, that.reachableType);
81+
public boolean equals(@Nullable Object other) {
82+
return (this == other || (other instanceof JdkProxyHint that &&
83+
this.proxiedInterfaces.equals(that.proxiedInterfaces) &&
84+
Objects.equals(this.reachableType, that.reachableType)));
9085
}
9186

9287
@Override
@@ -105,7 +100,6 @@ public static class Builder {
105100
@Nullable
106101
private TypeReference reachableType;
107102

108-
109103
Builder() {
110104
this.proxiedInterfaces = new LinkedList<>();
111105
}
@@ -131,10 +125,8 @@ public Builder proxiedInterfaces(Class<?>... proxiedInterfaces) {
131125
}
132126

133127
/**
134-
* Make this hint conditional on the fact that the specified type
135-
* can be resolved.
136-
* @param reachableType the type that should be reachable for this
137-
* hint to apply
128+
* Make this hint conditional on the fact that the specified type can be resolved.
129+
* @param reachableType the type that should be reachable for this hint to apply
138130
* @return {@code this}, to facilitate method chaining
139131
*/
140132
public Builder onReachableType(TypeReference reachableType) {
@@ -160,7 +152,6 @@ private static List<TypeReference> toTypeReferences(Class<?>... proxiedInterface
160152
}
161153
return TypeReference.listOf(proxiedInterfaces);
162154
}
163-
164155
}
165156

166157
}

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

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,9 +41,9 @@ public final class ResourceBundleHint implements ConditionalHint {
4141
this.reachableType = builder.reachableType;
4242
}
4343

44+
4445
/**
4546
* Return the {@code baseName} of the resource bundle.
46-
* @return the base name
4747
*/
4848
public String getBaseName() {
4949
return this.baseName;
@@ -56,23 +56,17 @@ public TypeReference getReachableType() {
5656
}
5757

5858
@Override
59-
public boolean equals(@Nullable Object o) {
60-
if (this == o) {
61-
return true;
62-
}
63-
if (o == null || getClass() != o.getClass()) {
64-
return false;
65-
}
66-
ResourceBundleHint that = (ResourceBundleHint) o;
67-
return this.baseName.equals(that.baseName)
68-
&& Objects.equals(this.reachableType, that.reachableType);
59+
public boolean equals(@Nullable Object other) {
60+
return (this == other || (other instanceof ResourceBundleHint that &&
61+
this.baseName.equals(that.baseName) && Objects.equals(this.reachableType, that.reachableType)));
6962
}
7063

7164
@Override
7265
public int hashCode() {
7366
return Objects.hash(this.baseName, this.reachableType);
7467
}
7568

69+
7670
/**
7771
* Builder for {@link ResourceBundleHint}.
7872
*/
@@ -88,10 +82,8 @@ public static class Builder {
8882
}
8983

9084
/**
91-
* Make this hint conditional on the fact that the specified type
92-
* can be resolved.
93-
* @param reachableType the type that should be reachable for this
94-
* hint to apply
85+
* Make this hint conditional on the fact that the specified type can be resolved.
86+
* @param reachableType the type that should be reachable for this hint to apply
9587
* @return {@code this}, to facilitate method chaining
9688
*/
9789
public Builder onReachableType(TypeReference reachableType) {
@@ -109,14 +101,12 @@ public Builder baseName(String baseName) {
109101
}
110102

111103
/**
112-
* Creates a {@link ResourceBundleHint} based on the state of this
113-
* builder.
104+
* Create a {@link ResourceBundleHint} based on the state of this builder.
114105
* @return a resource bundle hint
115106
*/
116107
ResourceBundleHint build() {
117108
return new ResourceBundleHint(this);
118109
}
119-
120110
}
121111

122112
}

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

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -71,15 +71,13 @@ public final class ResourcePatternHint implements ConditionalHint {
7171

7272
/**
7373
* Return the pattern to use for identifying the resources to match.
74-
* @return the pattern
7574
*/
7675
public String getPattern() {
7776
return this.pattern;
7877
}
7978

8079
/**
8180
* Return the regex {@link Pattern} to use for identifying the resources to match.
82-
* @return the regex pattern
8381
*/
8482
public Pattern toRegex() {
8583
String prefix = (this.pattern.startsWith("*") ? ".*" : "");
@@ -98,16 +96,9 @@ public TypeReference getReachableType() {
9896
}
9997

10098
@Override
101-
public boolean equals(@Nullable Object o) {
102-
if (this == o) {
103-
return true;
104-
}
105-
if (o == null || getClass() != o.getClass()) {
106-
return false;
107-
}
108-
ResourcePatternHint that = (ResourcePatternHint) o;
109-
return this.pattern.equals(that.pattern)
110-
&& Objects.equals(this.reachableType, that.reachableType);
99+
public boolean equals(@Nullable Object other) {
100+
return (this == other || (other instanceof ResourcePatternHint that &&
101+
this.pattern.equals(that.pattern) && Objects.equals(this.reachableType, that.reachableType)));
111102
}
112103

113104
@Override

0 commit comments

Comments
 (0)