Skip to content

Commit 24893d0

Browse files
committed
Polishing
1 parent b948237 commit 24893d0

File tree

6 files changed

+29
-36
lines changed

6 files changed

+29
-36
lines changed

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

Lines changed: 6 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.
@@ -39,6 +39,7 @@ final class BeanMethod extends ConfigurationMethod {
3939
super(metadata, configurationClass);
4040
}
4141

42+
4243
@Override
4344
public void validate(ProblemReporter problemReporter) {
4445
if (getMetadata().isStatic()) {
@@ -55,9 +56,9 @@ public void validate(ProblemReporter problemReporter) {
5556
}
5657

5758
@Override
58-
public boolean equals(@Nullable Object obj) {
59-
return ((this == obj) || ((obj instanceof BeanMethod) &&
60-
this.metadata.equals(((BeanMethod) obj).metadata)));
59+
public boolean equals(@Nullable Object other) {
60+
return (this == other || (other instanceof BeanMethod &&
61+
this.metadata.equals(((BeanMethod) other).metadata)));
6162
}
6263

6364
@Override
@@ -70,6 +71,7 @@ public String toString() {
7071
return "BeanMethod: " + this.metadata;
7172
}
7273

74+
7375
private class NonOverridableMethodError extends Problem {
7476

7577
NonOverridableMethodError() {

spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java

Lines changed: 2 additions & 4 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.
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
1817
package org.springframework.core;
1918

2019
import java.lang.reflect.ParameterizedType;
@@ -92,8 +91,7 @@ public String toString() {
9291
* @since 4.3.12
9392
*/
9493
public static <T> ParameterizedTypeReference<T> forType(Type type) {
95-
return new ParameterizedTypeReference<T>(type) {
96-
};
94+
return new ParameterizedTypeReference<T>(type) {};
9795
}
9896

9997
private static Class<?> findParameterizedTypeReferenceSubclass(Class<?> child) {

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,31 +168,27 @@ public boolean matches(Predicate<String> activeProfiles) {
168168
return false;
169169
}
170170

171-
@Override
172-
public int hashCode() {
173-
return this.expressions.hashCode();
174-
}
175-
176171
@Override
177172
public boolean equals(Object obj) {
178173
if (this == obj) {
179174
return true;
180175
}
181-
if (obj == null) {
182-
return false;
183-
}
184-
if (getClass() != obj.getClass()) {
176+
if (obj == null || getClass() != obj.getClass()) {
185177
return false;
186178
}
187179
ParsedProfiles that = (ParsedProfiles) obj;
188180
return this.expressions.equals(that.expressions);
189181
}
190182

183+
@Override
184+
public int hashCode() {
185+
return this.expressions.hashCode();
186+
}
187+
191188
@Override
192189
public String toString() {
193190
return StringUtils.collectionToDelimitedString(this.expressions, " or ");
194191
}
195-
196192
}
197193

198194
}

spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataReadingVisitor.java

Lines changed: 7 additions & 7 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.
@@ -171,6 +171,7 @@ private boolean isInterface(int access) {
171171
return (access & Opcodes.ACC_INTERFACE) != 0;
172172
}
173173

174+
174175
/**
175176
* {@link MergedAnnotation} source.
176177
*/
@@ -182,11 +183,6 @@ private static final class Source {
182183
this.className = className;
183184
}
184185

185-
@Override
186-
public int hashCode() {
187-
return this.className.hashCode();
188-
}
189-
190186
@Override
191187
public boolean equals(@Nullable Object obj) {
192188
if (this == obj) {
@@ -198,11 +194,15 @@ public boolean equals(@Nullable Object obj) {
198194
return this.className.equals(((Source) obj).className);
199195
}
200196

197+
@Override
198+
public int hashCode() {
199+
return this.className.hashCode();
200+
}
201+
201202
@Override
202203
public String toString() {
203204
return this.className;
204205
}
205-
206206
}
207207

208208
}

spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringFlushSynchronization.java

Lines changed: 1 addition & 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.
@@ -43,7 +43,6 @@ public void flush() {
4343
SessionFactoryUtils.flush(this.session, false);
4444
}
4545

46-
4746
@Override
4847
public boolean equals(@Nullable Object other) {
4948
return (this == other || (other instanceof SpringFlushSynchronization &&

spring-test/src/main/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizer.java

Lines changed: 7 additions & 9 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.
@@ -46,7 +46,6 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
4646

4747
private static final String PROPERTY_SOURCE_NAME = "Dynamic Test Properties";
4848

49-
5049
private final Set<Method> methods;
5150

5251

@@ -65,9 +64,7 @@ private void assertValid(Method method) {
6564
}
6665

6766
@Override
68-
public void customizeContext(ConfigurableApplicationContext context,
69-
MergedContextConfiguration mergedConfig) {
70-
67+
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
7168
MutablePropertySources sources = context.getEnvironment().getPropertySources();
7269
sources.addFirst(new DynamicValuesPropertySource(PROPERTY_SOURCE_NAME, buildDynamicPropertiesMap()));
7370
}
@@ -90,10 +87,6 @@ Set<Method> getMethods() {
9087
return this.methods;
9188
}
9289

93-
@Override
94-
public int hashCode() {
95-
return this.methods.hashCode();
96-
}
9790

9891
@Override
9992
public boolean equals(Object obj) {
@@ -106,4 +99,9 @@ public boolean equals(Object obj) {
10699
return this.methods.equals(((DynamicPropertiesContextCustomizer) obj).methods);
107100
}
108101

102+
@Override
103+
public int hashCode() {
104+
return this.methods.hashCode();
105+
}
106+
109107
}

0 commit comments

Comments
 (0)