Skip to content

Commit b4095c3

Browse files
committed
Class identity comparisons wherever possible
Issue: SPR-12926
1 parent 57e0c78 commit b4095c3

File tree

108 files changed

+317
-322
lines changed

Some content is hidden

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

108 files changed

+317
-322
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -381,7 +381,7 @@ else if (maybeBindJoinPointStaticPart(parameterTypes[0])) {
381381
}
382382

383383
private boolean maybeBindJoinPoint(Class<?> candidateParameterType) {
384-
if (candidateParameterType.equals(JoinPoint.class)) {
384+
if (JoinPoint.class == candidateParameterType) {
385385
this.joinPointArgumentIndex = 0;
386386
return true;
387387
}
@@ -391,7 +391,7 @@ private boolean maybeBindJoinPoint(Class<?> candidateParameterType) {
391391
}
392392

393393
private boolean maybeBindProceedingJoinPoint(Class<?> candidateParameterType) {
394-
if (candidateParameterType.equals(ProceedingJoinPoint.class)) {
394+
if (ProceedingJoinPoint.class == candidateParameterType) {
395395
if (!supportsProceedingJoinPoint()) {
396396
throw new IllegalArgumentException("ProceedingJoinPoint is only supported for around advice");
397397
}
@@ -408,7 +408,7 @@ protected boolean supportsProceedingJoinPoint() {
408408
}
409409

410410
private boolean maybeBindJoinPointStaticPart(Class<?> candidateParameterType) {
411-
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
411+
if (JoinPoint.StaticPart.class == candidateParameterType) {
412412
this.joinPointStaticPartArgumentIndex = 0;
413413
return true;
414414
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -93,7 +93,7 @@ private boolean matchesReturnValue(Class<?> type, Method method, Object returnVa
9393
if (returnValue != null) {
9494
return ClassUtils.isAssignableValue(type, returnValue);
9595
}
96-
else if (type.equals(Object.class) && method.getReturnType().equals(void.class)) {
96+
else if (Object.class == type && void.class == method.getReturnType()) {
9797
return true;
9898
}
9999
else{

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java

Lines changed: 2 additions & 2 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-2015 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.
@@ -72,7 +72,7 @@ public AspectMetadata(Class<?> aspectClass, String aspectName) {
7272

7373
Class<?> currClass = aspectClass;
7474
AjType<?> ajType = null;
75-
while (!currClass.equals(Object.class)) {
75+
while (currClass != Object.class) {
7676
AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
7777
if (ajTypeToCheck.isAspect()) {
7878
ajType = ajTypeToCheck;

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private Advisor getDeclareParentsAdvisor(Field introductionField) {
157157
return null;
158158
}
159159

160-
if (DeclareParents.class.equals(declareParents.defaultImpl())) {
160+
if (DeclareParents.class == declareParents.defaultImpl()) {
161161
// This is what comes back if it wasn't set. This seems bizarre...
162162
// TODO this restriction possibly should be relaxed
163163
throw new IllegalStateException("defaultImpl must be set on DeclareParents");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private void validateClassIfNecessary(Class<?> proxySuperClass, ClassLoader prox
255255
* methods across ClassLoaders, and writes warnings to the log for each one found.
256256
*/
257257
private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoader) {
258-
if (!Object.class.equals(proxySuperClass)) {
258+
if (Object.class != proxySuperClass) {
259259
Method[] methods = proxySuperClass.getDeclaredMethods();
260260
for (Method method : methods) {
261261
int mod = method.getModifiers();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException
7171
*/
7272
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
7373
Class<?>[] interfaces = config.getProxiedInterfaces();
74-
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class.equals(interfaces[0])));
74+
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class == interfaces[0]));
7575
}
7676

7777
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected void evaluateProxyInterfaces(Class<?> beanClass, ProxyFactory proxyFac
126126
* @return whether the given interface is just a container callback
127127
*/
128128
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
129-
return (ifc.equals(InitializingBean.class) || ifc.equals(DisposableBean.class) ||
129+
return (InitializingBean.class == ifc || DisposableBean.class == ifc ||
130130
ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
131131
}
132132

spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java

Lines changed: 2 additions & 2 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-2015 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.
@@ -109,7 +109,7 @@ private Method getExceptionHandler(Throwable exception) {
109109
logger.trace("Trying to find handler for exception of type [" + exceptionClass.getName() + "]");
110110
}
111111
Method handler = this.exceptionHandlerMap.get(exceptionClass);
112-
while (handler == null && !exceptionClass.equals(Throwable.class)) {
112+
while (handler == null && exceptionClass != Throwable.class) {
113113
exceptionClass = exceptionClass.getSuperclass();
114114
handler = this.exceptionHandlerMap.get(exceptionClass);
115115
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ else if (value instanceof Closure) {
619619
try {
620620
Closure callable = (Closure) value;
621621
Class<?> parameterType = callable.getParameterTypes()[0];
622-
if (parameterType.equals(Object.class)) {
622+
if (Object.class == parameterType) {
623623
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper("");
624624
callable.call(this.currentBeanDefinition);
625625
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -517,12 +517,12 @@ public static boolean isSimpleProperty(Class<?> clazz) {
517517
* @return whether the given type represents a "simple" value type
518518
*/
519519
public static boolean isSimpleValueType(Class<?> clazz) {
520-
return ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isEnum() ||
520+
return (ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isEnum() ||
521521
CharSequence.class.isAssignableFrom(clazz) ||
522522
Number.class.isAssignableFrom(clazz) ||
523523
Date.class.isAssignableFrom(clazz) ||
524-
clazz.equals(URI.class) || clazz.equals(URL.class) ||
525-
clazz.equals(Locale.class) || clazz.equals(Class.class);
524+
URI.class == clazz || URL.class == clazz ||
525+
Locale.class == clazz || Class.class == clazz);
526526
}
527527

528528

0 commit comments

Comments
 (0)