Skip to content

Commit f285971

Browse files
committed
Polishing
1 parent 89f6e8e commit f285971

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.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.
@@ -264,7 +264,7 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy mp
264264

265265
/**
266266
* CGLIB MethodInterceptor to override methods, replacing them with a call
267-
* to a generic MethodReplacer.
267+
* to a generic {@link MethodReplacer}.
268268
*/
269269
private static class ReplaceOverrideMethodInterceptor extends CglibIdentitySupport implements MethodInterceptor {
270270

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.java

+4-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.
@@ -49,7 +49,7 @@ public class LookupOverride extends MethodOverride {
4949

5050

5151
/**
52-
* Construct a new LookupOverride.
52+
* Construct a new {@code LookupOverride}.
5353
* @param methodName the name of the method to override
5454
* @param beanName the name of the bean in the current {@code BeanFactory} that the
5555
* overridden method should return (may be {@code null} for type-based bean retrieval)
@@ -60,7 +60,7 @@ public LookupOverride(String methodName, @Nullable String beanName) {
6060
}
6161

6262
/**
63-
* Construct a new LookupOverride.
63+
* Construct a new {@code LookupOverride}.
6464
* @param method the method declaration to override
6565
* @param beanName the name of the bean in the current {@code BeanFactory} that the
6666
* overridden method should return (may be {@code null} for type-based bean retrieval)
@@ -73,7 +73,7 @@ public LookupOverride(Method method, @Nullable String beanName) {
7373

7474

7575
/**
76-
* Return the name of the bean that should be returned by this method.
76+
* Return the name of the bean that should be returned by this {@code LookupOverride}.
7777
*/
7878
@Nullable
7979
public String getBeanName() {

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverride.java

+4-3
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.
@@ -17,6 +17,7 @@
1717
package org.springframework.beans.factory.support;
1818

1919
import java.lang.reflect.Method;
20+
import java.util.Objects;
2021

2122
import org.springframework.beans.BeanMetadataElement;
2223
import org.springframework.lang.Nullable;
@@ -107,13 +108,13 @@ public Object getSource() {
107108
@Override
108109
public boolean equals(@Nullable Object other) {
109110
return (this == other || (other instanceof MethodOverride that &&
110-
ObjectUtils.nullSafeEquals(this.methodName, that.methodName) &&
111+
this.methodName.equals(that.methodName) &&
111112
ObjectUtils.nullSafeEquals(this.source, that.source)));
112113
}
113114

114115
@Override
115116
public int hashCode() {
116-
return ObjectUtils.nullSafeHash(this.methodName, this.source);
117+
return Objects.hash(this.methodName, this.source);
117118
}
118119

119120
}

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java

+7-10
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.
@@ -19,10 +19,10 @@
1919
import java.lang.reflect.Method;
2020
import java.util.ArrayList;
2121
import java.util.List;
22+
import java.util.Objects;
2223

2324
import org.springframework.lang.Nullable;
2425
import org.springframework.util.Assert;
25-
import org.springframework.util.ObjectUtils;
2626

2727
/**
2828
* Extension of {@link MethodOverride} that represents an arbitrary
@@ -97,22 +97,19 @@ public boolean matches(Method method) {
9797

9898
@Override
9999
public boolean equals(@Nullable Object other) {
100-
return (other instanceof ReplaceOverride that && super.equals(other) &&
101-
ObjectUtils.nullSafeEquals(this.methodReplacerBeanName, that.methodReplacerBeanName) &&
102-
ObjectUtils.nullSafeEquals(this.typeIdentifiers, that.typeIdentifiers));
100+
return (other instanceof ReplaceOverride that && super.equals(that) &&
101+
this.methodReplacerBeanName.equals(that.methodReplacerBeanName) &&
102+
this.typeIdentifiers.equals(that.typeIdentifiers));
103103
}
104104

105105
@Override
106106
public int hashCode() {
107-
int hashCode = super.hashCode();
108-
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.methodReplacerBeanName);
109-
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.typeIdentifiers);
110-
return hashCode;
107+
return Objects.hash(this.methodReplacerBeanName, this.typeIdentifiers);
111108
}
112109

113110
@Override
114111
public String toString() {
115-
return "Replace override for method '" + getMethodName() + "'";
112+
return "ReplaceOverride for method '" + getMethodName() + "'";
116113
}
117114

118115
}

0 commit comments

Comments
 (0)