Class identity comparisons wherever possible
Issue: SPR-12926
This commit is contained in:
@@ -147,10 +147,10 @@ public class AnnotatedBeanDefinitionReader {
|
||||
AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);
|
||||
if (qualifiers != null) {
|
||||
for (Class<? extends Annotation> qualifier : qualifiers) {
|
||||
if (Primary.class.equals(qualifier)) {
|
||||
if (Primary.class == qualifier) {
|
||||
abd.setPrimary(true);
|
||||
}
|
||||
else if (Lazy.class.equals(qualifier)) {
|
||||
else if (Lazy.class == qualifier) {
|
||||
abd.setLazyInit(true);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,8 +62,8 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
|
||||
AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
|
||||
Object mode = candidate.get("mode");
|
||||
Object proxyTargetClass = candidate.get("proxyTargetClass");
|
||||
if (mode != null && proxyTargetClass != null && mode.getClass().equals(AdviceMode.class) &&
|
||||
proxyTargetClass.getClass().equals(Boolean.class)) {
|
||||
if (mode != null && proxyTargetClass != null && AdviceMode.class == mode.getClass() &&
|
||||
Boolean.class == proxyTargetClass.getClass()) {
|
||||
candidateFound = true;
|
||||
if (mode == AdviceMode.PROXY) {
|
||||
AopConfigUtils.registerAutoProxyCreatorIfNecessary(registry);
|
||||
|
||||
@@ -595,7 +595,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
else if (beanFactory instanceof ConfigurableBeanFactory){
|
||||
resourceName = ((ConfigurableBeanFactory) beanFactory).resolveEmbeddedValue(resourceName);
|
||||
}
|
||||
if (resourceType != null && !Object.class.equals(resourceType)) {
|
||||
if (resourceType != null && Object.class != resourceType) {
|
||||
checkResourceType(resourceType);
|
||||
}
|
||||
else {
|
||||
@@ -639,7 +639,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
resourceName = Introspector.decapitalize(resourceName.substring(3));
|
||||
}
|
||||
}
|
||||
if (resourceType != null && !Object.class.equals(resourceType)) {
|
||||
if (resourceType != null && Object.class != resourceType) {
|
||||
checkResourceType(resourceType);
|
||||
}
|
||||
else {
|
||||
@@ -652,7 +652,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
this.lookupType = resourceType;
|
||||
}
|
||||
else {
|
||||
this.lookupType = (!Object.class.equals(resource.value()) ? resource.value() : Service.class);
|
||||
this.lookupType = resource.value();
|
||||
}
|
||||
this.mappedName = resource.mappedName();
|
||||
this.wsdlLocation = resource.wsdlLocation();
|
||||
@@ -666,7 +666,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException notFound) {
|
||||
// Service to be created through generated class.
|
||||
if (Service.class.equals(this.lookupType)) {
|
||||
if (Service.class == this.lookupType) {
|
||||
throw new IllegalStateException("No resource with name '" + this.name + "' found in context, " +
|
||||
"and no specific JAX-WS Service subclass specified. The typical solution is to either specify " +
|
||||
"a LocalJaxWsServiceFactoryBean with the given name or to specify the (generated) Service " +
|
||||
@@ -723,7 +723,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
}
|
||||
}
|
||||
Class<?> resourceType = resource.beanInterface();
|
||||
if (resourceType != null && !Object.class.equals(resourceType)) {
|
||||
if (resourceType != null && Object.class != resourceType) {
|
||||
checkResourceType(resourceType);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -83,7 +83,7 @@ class ComponentScanAnnotationParser {
|
||||
scanner.setResourceLoader(this.resourceLoader);
|
||||
|
||||
Class<? extends BeanNameGenerator> generatorClass = componentScan.getClass("nameGenerator");
|
||||
boolean useInheritedGenerator = BeanNameGenerator.class.equals(generatorClass);
|
||||
boolean useInheritedGenerator = BeanNameGenerator.class == generatorClass;
|
||||
scanner.setBeanNameGenerator(useInheritedGenerator ? this.beanNameGenerator :
|
||||
BeanUtils.instantiateClass(generatorClass));
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ class ConfigurationClassBeanDefinitionReader {
|
||||
Class<? extends BeanDefinitionReader> readerClass = entry.getValue();
|
||||
|
||||
// Default reader selection necessary?
|
||||
if (readerClass.equals(BeanDefinitionReader.class)) {
|
||||
if (BeanDefinitionReader.class == readerClass) {
|
||||
if (StringUtils.endsWithIgnoreCase(resource, ".groovy")) {
|
||||
// When clearly asking for Groovy, that's what they'll get...
|
||||
readerClass = GroovyBeanDefinitionReader.class;
|
||||
|
||||
@@ -240,7 +240,7 @@ class ConfigurationClassEnhancer {
|
||||
public boolean isMatch(Method candidateMethod) {
|
||||
return (candidateMethod.getName().equals("setBeanFactory") &&
|
||||
candidateMethod.getParameterTypes().length == 1 &&
|
||||
candidateMethod.getParameterTypes()[0].equals(BeanFactory.class) &&
|
||||
BeanFactory.class == candidateMethod.getParameterTypes()[0] &&
|
||||
BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ContextAnnotationAutowireCandidateResolver extends QualifierAnnotat
|
||||
MethodParameter methodParam = descriptor.getMethodParameter();
|
||||
if (methodParam != null) {
|
||||
Method method = methodParam.getMethod();
|
||||
if (method == null || void.class.equals(method.getReturnType())) {
|
||||
if (method == null || void.class == method.getReturnType()) {
|
||||
Lazy lazy = AnnotationUtils.getAnnotation(methodParam.getAnnotatedElement(), Lazy.class);
|
||||
if (lazy != null && lazy.value()) {
|
||||
return true;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class EventPublicationInterceptor
|
||||
* if it does not expose a constructor that takes a single {@code Object} argument
|
||||
*/
|
||||
public void setApplicationEventClass(Class<?> applicationEventClass) {
|
||||
if (ApplicationEvent.class.equals(applicationEventClass) ||
|
||||
if (ApplicationEvent.class == applicationEventClass ||
|
||||
!ApplicationEvent.class.isAssignableFrom(applicationEventClass)) {
|
||||
throw new IllegalArgumentException("applicationEventClass needs to extend ApplicationEvent");
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ public class JodaDateTimeFormatAnnotationFormatterFactory extends EmbeddedValueR
|
||||
|
||||
@Override
|
||||
public Parser<?> getParser(DateTimeFormat annotation, Class<?> fieldType) {
|
||||
if (LocalDate.class.equals(fieldType)) {
|
||||
if (LocalDate.class == fieldType) {
|
||||
return new LocalDateParser(getFormatter(annotation, fieldType));
|
||||
}
|
||||
else if (LocalTime.class.equals(fieldType)) {
|
||||
else if (LocalTime.class == fieldType) {
|
||||
return new LocalTimeParser(getFormatter(annotation, fieldType));
|
||||
}
|
||||
else if (LocalDateTime.class.equals(fieldType)) {
|
||||
else if (LocalDateTime.class == fieldType) {
|
||||
return new LocalDateTimeParser(getFormatter(annotation, fieldType));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -67,22 +67,22 @@ public final class TemporalAccessorParser implements Parser<TemporalAccessor> {
|
||||
@Override
|
||||
public TemporalAccessor parse(String text, Locale locale) throws ParseException {
|
||||
DateTimeFormatter formatterToUse = DateTimeContextHolder.getFormatter(this.formatter, locale);
|
||||
if (LocalDate.class.equals(this.temporalAccessorType)) {
|
||||
if (LocalDate.class == this.temporalAccessorType) {
|
||||
return LocalDate.parse(text, formatterToUse);
|
||||
}
|
||||
else if (LocalTime.class.equals(this.temporalAccessorType)) {
|
||||
else if (LocalTime.class == this.temporalAccessorType) {
|
||||
return LocalTime.parse(text, formatterToUse);
|
||||
}
|
||||
else if (LocalDateTime.class.equals(this.temporalAccessorType)) {
|
||||
else if (LocalDateTime.class == this.temporalAccessorType) {
|
||||
return LocalDateTime.parse(text, formatterToUse);
|
||||
}
|
||||
else if (ZonedDateTime.class.equals(this.temporalAccessorType)) {
|
||||
else if (ZonedDateTime.class == this.temporalAccessorType) {
|
||||
return ZonedDateTime.parse(text, formatterToUse);
|
||||
}
|
||||
else if (OffsetDateTime.class.equals(this.temporalAccessorType)) {
|
||||
else if (OffsetDateTime.class == this.temporalAccessorType) {
|
||||
return OffsetDateTime.parse(text, formatterToUse);
|
||||
}
|
||||
else if (OffsetTime.class.equals(this.temporalAccessorType)) {
|
||||
else if (OffsetTime.class == this.temporalAccessorType) {
|
||||
return OffsetTime.parse(text, formatterToUse);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -352,7 +352,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
|
||||
if (method.isSynthetic()) {
|
||||
continue;
|
||||
}
|
||||
if (method.getDeclaringClass().equals(Object.class)) {
|
||||
if (Object.class == method.getDeclaringClass()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -368,7 +368,7 @@ public class JndiObjectFactoryBean extends JndiObjectLocator
|
||||
}
|
||||
|
||||
protected boolean isEligible(Method method) {
|
||||
return !Object.class.equals(method.getDeclaringClass());
|
||||
return (Object.class != method.getDeclaringClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public class ScheduledAnnotationBeanPostProcessor implements BeanPostProcessor,
|
||||
|
||||
protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
|
||||
try {
|
||||
Assert.isTrue(void.class.equals(method.getReturnType()),
|
||||
Assert.isTrue(void.class == method.getReturnType(),
|
||||
"Only void-returning methods may be annotated with @Scheduled");
|
||||
Assert.isTrue(method.getParameterTypes().length == 0,
|
||||
"Only no-arg methods may be annotated with @Scheduled");
|
||||
|
||||
Reference in New Issue
Block a user