Skip to content

Commit 40efcc9

Browse files
committed
Polishing
1 parent b68e692 commit 40efcc9

File tree

107 files changed

+506
-620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+506
-620
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,20 +291,20 @@ private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
291291
// unadvised but can return this). May be required to expose the proxy.
292292
Callback targetInterceptor;
293293
if (exposeProxy) {
294-
targetInterceptor = isStatic ?
294+
targetInterceptor = (isStatic ?
295295
new StaticUnadvisedExposedInterceptor(this.advised.getTargetSource().getTarget()) :
296-
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource());
296+
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource()));
297297
}
298298
else {
299-
targetInterceptor = isStatic ?
299+
targetInterceptor = (isStatic ?
300300
new StaticUnadvisedInterceptor(this.advised.getTargetSource().getTarget()) :
301-
new DynamicUnadvisedInterceptor(this.advised.getTargetSource());
301+
new DynamicUnadvisedInterceptor(this.advised.getTargetSource()));
302302
}
303303

304304
// Choose a "direct to target" dispatcher (used for
305305
// unadvised calls to static targets that cannot return this).
306-
Callback targetDispatcher = isStatic ?
307-
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp();
306+
Callback targetDispatcher = (isStatic ?
307+
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp());
308308

309309
Callback[] mainCallbacks = new Callback[] {
310310
aopInterceptor, // for normal advice

spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java

Lines changed: 2 additions & 2 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-2018 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.
@@ -131,7 +131,7 @@ public boolean equals(Object other) {
131131
return false;
132132
}
133133
ControlFlowPointcut that = (ControlFlowPointcut) other;
134-
return (this.clazz.equals(that.clazz)) && ObjectUtils.nullSafeEquals(that.methodName, this.methodName);
134+
return (this.clazz.equals(that.clazz)) && ObjectUtils.nullSafeEquals(this.methodName, that.methodName);
135135
}
136136

137137
@Override

spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ public boolean matches(Method method, @Nullable Class<?> targetClass, Object...
144144
}
145145

146146
@Override
147-
public boolean equals(Object obj) {
148-
if (this == obj) {
147+
public boolean equals(Object other) {
148+
if (this == other) {
149149
return true;
150150
}
151-
if (!(obj instanceof UnionMethodMatcher)) {
151+
if (!(other instanceof UnionMethodMatcher)) {
152152
return false;
153153
}
154-
UnionMethodMatcher that = (UnionMethodMatcher) obj;
154+
UnionMethodMatcher that = (UnionMethodMatcher) other;
155155
return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2));
156156
}
157157

@@ -239,29 +239,29 @@ public IntersectionMethodMatcher(MethodMatcher mm1, MethodMatcher mm2) {
239239

240240
@Override
241241
public boolean matches(Method method, @Nullable Class<?> targetClass, boolean hasIntroductions) {
242-
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
243-
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
242+
return (MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
243+
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
244244
}
245245

246246
@Override
247247
public boolean matches(Method method, @Nullable Class<?> targetClass) {
248-
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass);
248+
return (this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass));
249249
}
250250

251251
@Override
252252
public boolean isRuntime() {
253-
return this.mm1.isRuntime() || this.mm2.isRuntime();
253+
return (this.mm1.isRuntime() || this.mm2.isRuntime());
254254
}
255255

256256
@Override
257257
public boolean matches(Method method, @Nullable Class<?> targetClass, Object... args) {
258258
// Because a dynamic intersection may be composed of a static and dynamic part,
259259
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
260260
// it will probably be an unsupported operation.
261-
boolean aMatches = this.mm1.isRuntime() ?
262-
this.mm1.matches(method, targetClass, args) : this.mm1.matches(method, targetClass);
263-
boolean bMatches = this.mm2.isRuntime() ?
264-
this.mm2.matches(method, targetClass, args) : this.mm2.matches(method, targetClass);
261+
boolean aMatches = (this.mm1.isRuntime() ?
262+
this.mm1.matches(method, targetClass, args) : this.mm1.matches(method, targetClass));
263+
boolean bMatches = (this.mm2.isRuntime() ?
264+
this.mm2.matches(method, targetClass, args) : this.mm2.matches(method, targetClass));
265265
return aMatches && bMatches;
266266
}
267267

spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,8 @@ public boolean isConverted() {
348348

349349
@Override
350350
public boolean equals(Object other) {
351-
if (this == other) {
352-
return true;
353-
}
354-
if (!(other instanceof MutablePropertyValues)) {
355-
return false;
356-
}
357-
MutablePropertyValues that = (MutablePropertyValues) other;
358-
return this.propertyValueList.equals(that.propertyValueList);
351+
return (this == other || (other instanceof MutablePropertyValues &&
352+
this.propertyValueList.equals(((MutablePropertyValues) other).propertyValueList)));
359353
}
360354

361355
@Override

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class CannotLoadBeanClassException extends FatalBeanException {
3232
@Nullable
3333
private final String resourceDescription;
3434

35-
@Nullable
3635
private final String beanName;
3736

3837
@Nullable
@@ -47,8 +46,8 @@ public class CannotLoadBeanClassException extends FatalBeanException {
4746
* @param beanClassName the name of the bean class
4847
* @param cause the root cause
4948
*/
50-
public CannotLoadBeanClassException(
51-
@Nullable String resourceDescription, String beanName, @Nullable String beanClassName, ClassNotFoundException cause) {
49+
public CannotLoadBeanClassException(@Nullable String resourceDescription, String beanName,
50+
@Nullable String beanClassName, ClassNotFoundException cause) {
5251

5352
super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName + "'" +
5453
(resourceDescription != null ? " defined in " + resourceDescription : ""), cause);
@@ -65,8 +64,8 @@ public CannotLoadBeanClassException(
6564
* @param beanClassName the name of the bean class
6665
* @param cause the root cause
6766
*/
68-
public CannotLoadBeanClassException(
69-
@Nullable String resourceDescription, String beanName, @Nullable String beanClassName, LinkageError cause) {
67+
public CannotLoadBeanClassException(@Nullable String resourceDescription, String beanName,
68+
@Nullable String beanClassName, LinkageError cause) {
7069

7170
super("Error loading class [" + beanClassName + "] for bean with name '" + beanName + "'" +
7271
(resourceDescription != null ? " defined in " + resourceDescription : "") +
@@ -89,7 +88,6 @@ public String getResourceDescription() {
8988
/**
9089
* Return the name of the bean requested.
9190
*/
92-
@Nullable
9391
public String getBeanName() {
9492
return this.beanName;
9593
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ else if (this.targetField == null) {
203203
}
204204

205205
// Try to get the exact method first.
206-
Class<?> targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass;
206+
Class<?> targetClass = (this.targetObject != null ? this.targetObject.getClass() : this.targetClass);
207207
this.fieldObject = targetClass.getField(this.targetField);
208208
}
209209

spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ else if ("ref".equals(name)) {
374374
if (args[0] == null) {
375375
throw new IllegalArgumentException("Argument to ref() is not a valid bean or was not found");
376376
}
377-
378377
if (args[0] instanceof RuntimeBeanReference) {
379378
refName = ((RuntimeBeanReference) args[0]).getBeanName();
380379
}
@@ -490,11 +489,11 @@ else if (args[0] instanceof Map) {
490489
Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next();
491490
// If we have a closure body, that will be the last argument.
492491
// In between are the constructor args
493-
int constructorArgsTest = hasClosureArgument?2:1;
492+
int constructorArgsTest = (hasClosureArgument ? 2 : 1);
494493
// If we have more than this number of args, we have constructor args
495494
if (args.length > constructorArgsTest){
496495
// factory-method requires args
497-
int endOfConstructArgs = (hasClosureArgument? args.length - 1 : args.length);
496+
int endOfConstructArgs = (hasClosureArgument ? args.length - 1 : args.length);
498497
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null,
499498
resolveConstructorArguments(args, 1, endOfConstructArgs));
500499
}

spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -82,7 +82,7 @@ public void pop() {
8282
*/
8383
@Nullable
8484
public Entry peek() {
85-
return this.state.isEmpty() ? null : this.state.peek();
85+
return this.state.peek();
8686
}
8787

8888
/**

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

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,39 +1114,38 @@ public Object clone() {
11141114
public abstract AbstractBeanDefinition cloneBeanDefinition();
11151115

11161116
@Override
1117-
public boolean equals(Object obj) {
1118-
if (this == obj) {
1117+
public boolean equals(Object other) {
1118+
if (this == other) {
11191119
return true;
11201120
}
1121-
if (!(obj instanceof AbstractBeanDefinition)) {
1121+
if (!(other instanceof AbstractBeanDefinition)) {
11221122
return false;
11231123
}
1124-
AbstractBeanDefinition other = (AbstractBeanDefinition) obj;
1125-
boolean rtn = true;
1126-
rtn = rtn &= ObjectUtils.nullSafeEquals(getBeanClassName(), other.getBeanClassName());
1127-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.scope, other.scope);
1128-
rtn = rtn &= this.abstractFlag == other.abstractFlag;
1129-
rtn = rtn &= this.lazyInit == other.lazyInit;
1130-
rtn = rtn &= this.autowireMode == other.autowireMode;
1131-
rtn = rtn &= this.dependencyCheck == other.dependencyCheck;
1132-
rtn = rtn &= Arrays.equals(this.dependsOn, other.dependsOn);
1133-
rtn = rtn &= this.autowireCandidate == other.autowireCandidate;
1134-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.qualifiers, other.qualifiers);
1135-
rtn = rtn &= this.primary == other.primary;
1136-
rtn = rtn &= this.nonPublicAccessAllowed == other.nonPublicAccessAllowed;
1137-
rtn = rtn &= this.lenientConstructorResolution == other.lenientConstructorResolution;
1138-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.constructorArgumentValues, other.constructorArgumentValues);
1139-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.propertyValues, other.propertyValues);
1140-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.methodOverrides, other.methodOverrides);
1141-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryBeanName, other.factoryBeanName);
1142-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryMethodName, other.factoryMethodName);
1143-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.initMethodName, other.initMethodName);
1144-
rtn = rtn &= this.enforceInitMethod == other.enforceInitMethod;
1145-
rtn = rtn &= ObjectUtils.nullSafeEquals(this.destroyMethodName, other.destroyMethodName);
1146-
rtn = rtn &= this.enforceDestroyMethod == other.enforceDestroyMethod;
1147-
rtn = rtn &= this.synthetic == other.synthetic;
1148-
rtn = rtn &= this.role == other.role;
1149-
return rtn && super.equals(obj);
1124+
AbstractBeanDefinition that = (AbstractBeanDefinition) other;
1125+
boolean rtn = ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName());
1126+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.scope, that.scope);
1127+
rtn = rtn &= this.abstractFlag == that.abstractFlag;
1128+
rtn = rtn &= this.lazyInit == that.lazyInit;
1129+
rtn = rtn &= this.autowireMode == that.autowireMode;
1130+
rtn = rtn &= this.dependencyCheck == that.dependencyCheck;
1131+
rtn = rtn &= Arrays.equals(this.dependsOn, that.dependsOn);
1132+
rtn = rtn &= this.autowireCandidate == that.autowireCandidate;
1133+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers);
1134+
rtn = rtn &= this.primary == that.primary;
1135+
rtn = rtn &= this.nonPublicAccessAllowed == that.nonPublicAccessAllowed;
1136+
rtn = rtn &= this.lenientConstructorResolution == that.lenientConstructorResolution;
1137+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues);
1138+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues);
1139+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides);
1140+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName);
1141+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName);
1142+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName);
1143+
rtn = rtn &= this.enforceInitMethod == that.enforceInitMethod;
1144+
rtn = rtn &= ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName);
1145+
rtn = rtn &= this.enforceDestroyMethod == that.enforceDestroyMethod;
1146+
rtn = rtn &= this.synthetic == that.synthetic;
1147+
rtn = rtn &= this.role == that.role;
1148+
return rtn && super.equals(other);
11501149
}
11511150

11521151
@Override

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -80,10 +80,9 @@ public String getDescription() {
8080
* This implementation compares the underlying BeanDefinition.
8181
*/
8282
@Override
83-
public boolean equals(Object obj) {
84-
return (obj == this ||
85-
(obj instanceof BeanDefinitionResource &&
86-
((BeanDefinitionResource) obj).beanDefinition.equals(this.beanDefinition)));
83+
public boolean equals(Object other) {
84+
return (this == other || (other instanceof BeanDefinitionResource &&
85+
((BeanDefinitionResource) other).beanDefinition.equals(this.beanDefinition)));
8786
}
8887

8988
/**

0 commit comments

Comments
 (0)