Skip to content

Commit a7b7466

Browse files
committed
Polishing
1 parent 3a8c0db commit a7b7466

File tree

22 files changed

+93
-86
lines changed

22 files changed

+93
-86
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -248,8 +248,8 @@ private PointcutParser initializePointcutParser(@Nullable ClassLoader classLoade
248248

249249
/**
250250
* If a pointcut expression has been specified in XML, the user cannot
251-
* write {@code and} as "&&" (though && will work).
252-
* We also allow {@code and} between two pointcut sub-expressions.
251+
* write "and" as "&&" (though {@code &&} will work).
252+
* <p>We also allow "and" between two pointcut sub-expressions.
253253
* <p>This method converts back to {@code &&} for the AspectJ pointcut parser.
254254
*/
255255
private String replaceBooleanOperators(String pcExpr) {
@@ -527,15 +527,15 @@ public boolean equals(@Nullable Object other) {
527527
return false;
528528
}
529529
AspectJExpressionPointcut otherPc = (AspectJExpressionPointcut) other;
530-
return ObjectUtils.nullSafeEquals(this.getExpression(), otherPc.getExpression()) &&
530+
return ObjectUtils.nullSafeEquals(getExpression(), otherPc.getExpression()) &&
531531
ObjectUtils.nullSafeEquals(this.pointcutDeclarationScope, otherPc.pointcutDeclarationScope) &&
532532
ObjectUtils.nullSafeEquals(this.pointcutParameterNames, otherPc.pointcutParameterNames) &&
533533
ObjectUtils.nullSafeEquals(this.pointcutParameterTypes, otherPc.pointcutParameterTypes);
534534
}
535535

536536
@Override
537537
public int hashCode() {
538-
int hashCode = ObjectUtils.nullSafeHashCode(this.getExpression());
538+
int hashCode = ObjectUtils.nullSafeHashCode(getExpression());
539539
hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(this.pointcutDeclarationScope);
540540
hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(this.pointcutParameterNames);
541541
hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(this.pointcutParameterTypes);

spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,9 @@ public static class SerializableNoOp implements NoOp, Serializable {
424424

425425

426426
/**
427-
* Method interceptor used for static targets with no advice chain. The call
428-
* is passed directly back to the target. Used when the proxy needs to be
429-
* exposed and it can't be determined that the method won't return
430-
* {@code this}.
427+
* Method interceptor used for static targets with no advice chain. The call is
428+
* passed directly back to the target. Used when the proxy needs to be exposed
429+
* and it can't be determined that the method won't return {@code this}.
431430
*/
432431
private static class StaticUnadvisedInterceptor implements MethodInterceptor, Serializable {
433432

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -112,7 +112,7 @@ public boolean equals(@Nullable Object other) {
112112

113113
@Override
114114
public int hashCode() {
115-
return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.beanName));
115+
return super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.beanName);
116116
}
117117

118118
@Override

spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -477,7 +477,7 @@ public boolean equals(Object other) {
477477

478478
@Override
479479
public int hashCode() {
480-
return this.age;
480+
return TestBean.class.hashCode();
481481
}
482482

483483
@Override

spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -65,7 +65,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
6565
* through {@link #register} calls and then manually {@linkplain #refresh refreshed}.
6666
*/
6767
public AnnotationConfigApplicationContext() {
68-
StartupStep createAnnotatedBeanDefReader = this.getApplicationStartup().start("spring.context.annotated-bean-reader.create");
68+
StartupStep createAnnotatedBeanDefReader = getApplicationStartup().start("spring.context.annotated-bean-reader.create");
6969
this.reader = new AnnotatedBeanDefinitionReader(this);
7070
createAnnotatedBeanDefReader.end();
7171
this.scanner = new ClassPathBeanDefinitionScanner(this);
@@ -163,7 +163,7 @@ public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver
163163
@Override
164164
public void register(Class<?>... componentClasses) {
165165
Assert.notEmpty(componentClasses, "At least one component class must be specified");
166-
StartupStep registerComponentClass = this.getApplicationStartup().start("spring.context.component-classes.register")
166+
StartupStep registerComponentClass = getApplicationStartup().start("spring.context.component-classes.register")
167167
.tag("classes", () -> Arrays.toString(componentClasses));
168168
this.reader.register(componentClasses);
169169
registerComponentClass.end();
@@ -180,7 +180,7 @@ public void register(Class<?>... componentClasses) {
180180
@Override
181181
public void scan(String... basePackages) {
182182
Assert.notEmpty(basePackages, "At least one base package must be specified");
183-
StartupStep scanPackages = this.getApplicationStartup().start("spring.context.base-packages.scan")
183+
StartupStep scanPackages = getApplicationStartup().start("spring.context.base-packages.scan")
184184
.tag("packages", () -> Arrays.toString(basePackages));
185185
this.scanner.scan(basePackages);
186186
scanPackages.end();

spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.beans.BeansException;
2222
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
23+
import org.springframework.beans.factory.xml.BeanDefinitionDocumentReader;
2324
import org.springframework.beans.factory.xml.ResourceEntityResolver;
2425
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
2526
import org.springframework.context.ApplicationContext;
@@ -84,7 +85,7 @@ protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throw
8485

8586
// Configure the bean definition reader with this context's
8687
// resource loading environment.
87-
beanDefinitionReader.setEnvironment(this.getEnvironment());
88+
beanDefinitionReader.setEnvironment(getEnvironment());
8889
beanDefinitionReader.setResourceLoader(this);
8990
beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
9091

@@ -95,12 +96,13 @@ protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throw
9596
}
9697

9798
/**
98-
* Initialize the bean definition reader used for loading the bean
99-
* definitions of this context. Default implementation is empty.
99+
* Initialize the bean definition reader used for loading the bean definitions
100+
* of this context. The default implementation sets the validating flag.
100101
* <p>Can be overridden in subclasses, e.g. for turning off XML validation
101-
* or using a different XmlBeanDefinitionParser implementation.
102+
* or using a different {@link BeanDefinitionDocumentReader} implementation.
102103
* @param reader the bean definition reader used by this context
103-
* @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setDocumentReaderClass
104+
* @see XmlBeanDefinitionReader#setValidating
105+
* @see XmlBeanDefinitionReader#setDocumentReaderClass
104106
*/
105107
protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
106108
reader.setValidating(this.validating);

spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2023 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.

spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -252,7 +252,7 @@ public void setNonOptionArgsPropertyName(String nonOptionArgsPropertyName) {
252252
@Override
253253
public final boolean containsProperty(String name) {
254254
if (this.nonOptionArgsPropertyName.equals(name)) {
255-
return !this.getNonOptionArgs().isEmpty();
255+
return !getNonOptionArgs().isEmpty();
256256
}
257257
return this.containsOption(name);
258258
}
@@ -270,15 +270,15 @@ public final boolean containsProperty(String name) {
270270
@Nullable
271271
public final String getProperty(String name) {
272272
if (this.nonOptionArgsPropertyName.equals(name)) {
273-
Collection<String> nonOptionArguments = this.getNonOptionArgs();
273+
Collection<String> nonOptionArguments = getNonOptionArgs();
274274
if (nonOptionArguments.isEmpty()) {
275275
return null;
276276
}
277277
else {
278278
return StringUtils.collectionToCommaDelimitedString(nonOptionArguments);
279279
}
280280
}
281-
Collection<String> optionValues = this.getOptionValues(name);
281+
Collection<String> optionValues = getOptionValues(name);
282282
if (optionValues == null) {
283283
return null;
284284
}

spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -752,28 +752,27 @@ public V setValue(@Nullable V value) {
752752
}
753753

754754
@Override
755-
public String toString() {
756-
return (this.key + "=" + this.value);
757-
}
758-
759-
@Override
760-
@SuppressWarnings("rawtypes")
761-
public final boolean equals(@Nullable Object other) {
755+
public boolean equals(@Nullable Object other) {
762756
if (this == other) {
763757
return true;
764758
}
765-
if (!(other instanceof Map.Entry)) {
759+
if (!(other instanceof Map.Entry<?, ?>)) {
766760
return false;
767761
}
768-
Map.Entry otherEntry = (Map.Entry) other;
762+
Map.Entry<?, ?> otherEntry = (Map.Entry<?, ?>) other;
769763
return (ObjectUtils.nullSafeEquals(getKey(), otherEntry.getKey()) &&
770764
ObjectUtils.nullSafeEquals(getValue(), otherEntry.getValue()));
771765
}
772766

773767
@Override
774-
public final int hashCode() {
768+
public int hashCode() {
775769
return (ObjectUtils.nullSafeHashCode(this.key) ^ ObjectUtils.nullSafeHashCode(this.value));
776770
}
771+
772+
@Override
773+
public String toString() {
774+
return (this.key + "=" + this.value);
775+
}
777776
}
778777

779778

spring-core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -85,7 +85,7 @@ private NullSafeComparator(boolean nullsLow) {
8585
* @param nullsLow whether to treat nulls lower or higher than non-null objects
8686
*/
8787
public NullSafeComparator(Comparator<T> comparator, boolean nullsLow) {
88-
Assert.notNull(comparator, "Non-null Comparator is required");
88+
Assert.notNull(comparator, "Comparator must not be null");
8989
this.nonNullComparator = comparator;
9090
this.nullsLow = nullsLow;
9191
}
@@ -107,16 +107,16 @@ public int compare(@Nullable T o1, @Nullable T o2) {
107107

108108

109109
@Override
110-
@SuppressWarnings("unchecked")
111110
public boolean equals(@Nullable Object other) {
112111
if (this == other) {
113112
return true;
114113
}
115-
if (!(other instanceof NullSafeComparator)) {
114+
if (!(other instanceof NullSafeComparator<?>)) {
116115
return false;
117116
}
118-
NullSafeComparator<T> otherComp = (NullSafeComparator<T>) other;
119-
return (this.nonNullComparator.equals(otherComp.nonNullComparator) && this.nullsLow == otherComp.nullsLow);
117+
NullSafeComparator<?> otherComp = (NullSafeComparator<?>) other;
118+
return (this.nonNullComparator.equals(otherComp.nonNullComparator) &&
119+
this.nullsLow == otherComp.nullsLow);
120120
}
121121

122122
@Override

0 commit comments

Comments
 (0)