Class identity comparisons wherever possible

Issue: SPR-12926
This commit is contained in:
Juergen Hoeller 2015-05-20 14:34:09 +02:00
parent 57e0c789a8
commit b4095c3e1d
108 changed files with 317 additions and 322 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -381,7 +381,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
private boolean maybeBindJoinPoint(Class<?> candidateParameterType) {
if (candidateParameterType.equals(JoinPoint.class)) {
if (JoinPoint.class == candidateParameterType) {
this.joinPointArgumentIndex = 0;
return true;
}
@ -391,7 +391,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
private boolean maybeBindProceedingJoinPoint(Class<?> candidateParameterType) {
if (candidateParameterType.equals(ProceedingJoinPoint.class)) {
if (ProceedingJoinPoint.class == candidateParameterType) {
if (!supportsProceedingJoinPoint()) {
throw new IllegalArgumentException("ProceedingJoinPoint is only supported for around advice");
}
@ -408,7 +408,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
private boolean maybeBindJoinPointStaticPart(Class<?> candidateParameterType) {
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
if (JoinPoint.StaticPart.class == candidateParameterType) {
this.joinPointStaticPartArgumentIndex = 0;
return true;
}

View File

@ -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.
@ -93,7 +93,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
if (returnValue != null) {
return ClassUtils.isAssignableValue(type, returnValue);
}
else if (type.equals(Object.class) && method.getReturnType().equals(void.class)) {
else if (Object.class == type && void.class == method.getReturnType()) {
return true;
}
else{

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@ -72,7 +72,7 @@ public class AspectMetadata {
Class<?> currClass = aspectClass;
AjType<?> ajType = null;
while (!currClass.equals(Object.class)) {
while (currClass != Object.class) {
AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
if (ajTypeToCheck.isAspect()) {
ajType = ajTypeToCheck;

View File

@ -157,7 +157,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
return null;
}
if (DeclareParents.class.equals(declareParents.defaultImpl())) {
if (DeclareParents.class == declareParents.defaultImpl()) {
// This is what comes back if it wasn't set. This seems bizarre...
// TODO this restriction possibly should be relaxed
throw new IllegalStateException("defaultImpl must be set on DeclareParents");

View File

@ -255,7 +255,7 @@ class CglibAopProxy implements AopProxy, Serializable {
* methods across ClassLoaders, and writes warnings to the log for each one found.
*/
private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoader) {
if (!Object.class.equals(proxySuperClass)) {
if (Object.class != proxySuperClass) {
Method[] methods = proxySuperClass.getDeclaredMethods();
for (Method method : methods) {
int mod = method.getModifiers();

View File

@ -71,7 +71,7 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
*/
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
Class<?>[] interfaces = config.getProxiedInterfaces();
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class.equals(interfaces[0])));
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class == interfaces[0]));
}
}

View File

@ -126,7 +126,7 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
* @return whether the given interface is just a container callback
*/
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
return (ifc.equals(InitializingBean.class) || ifc.equals(DisposableBean.class) ||
return (InitializingBean.class == ifc || DisposableBean.class == ifc ||
ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@ -109,7 +109,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
logger.trace("Trying to find handler for exception of type [" + exceptionClass.getName() + "]");
}
Method handler = this.exceptionHandlerMap.get(exceptionClass);
while (handler == null && !exceptionClass.equals(Throwable.class)) {
while (handler == null && exceptionClass != Throwable.class) {
exceptionClass = exceptionClass.getSuperclass();
handler = this.exceptionHandlerMap.get(exceptionClass);
}

View File

@ -619,7 +619,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
try {
Closure callable = (Closure) value;
Class<?> parameterType = callable.getParameterTypes()[0];
if (parameterType.equals(Object.class)) {
if (Object.class == parameterType) {
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper("");
callable.call(this.currentBeanDefinition);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -517,12 +517,12 @@ public abstract class BeanUtils {
* @return whether the given type represents a "simple" value type
*/
public static boolean isSimpleValueType(Class<?> clazz) {
return ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isEnum() ||
return (ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isEnum() ||
CharSequence.class.isAssignableFrom(clazz) ||
Number.class.isAssignableFrom(clazz) ||
Date.class.isAssignableFrom(clazz) ||
clazz.equals(URI.class) || clazz.equals(URL.class) ||
clazz.equals(Locale.class) || clazz.equals(Class.class);
URI.class == clazz || URL.class == clazz ||
Locale.class == clazz || Class.class == clazz);
}

View File

@ -288,7 +288,7 @@ public class CachedIntrospectionResults {
// This call is slow so we do it once.
PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors();
for (PropertyDescriptor pd : pds) {
if (Class.class.equals(beanClass) &&
if (Class.class == beanClass &&
("classLoader".equals(pd.getName()) || "protectionDomain".equals(pd.getName()))) {
// Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those
continue;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -153,7 +153,7 @@ class ExtendedBeanInfo implements BeanInfo {
int nParams = parameterTypes.length;
return (methodName.length() > 3 && methodName.startsWith("set") && Modifier.isPublic(method.getModifiers()) &&
(!void.class.isAssignableFrom(method.getReturnType()) || Modifier.isStatic(method.getModifiers())) &&
(nParams == 1 || (nParams == 2 && parameterTypes[0].equals(int.class))));
(nParams == 1 || (nParams == 2 && int.class == parameterTypes[0])));
}
private void handleCandidateWriteMethod(Method method) throws IntrospectionException {

View File

@ -201,7 +201,7 @@ class TypeConverterDelegate {
// Try to apply some standard type conversion rules if appropriate.
if (convertedValue != null) {
if (Object.class.equals(requiredType)) {
if (Object.class == requiredType) {
return (T) convertedValue;
}
else if (requiredType.isArray()) {
@ -227,7 +227,7 @@ class TypeConverterDelegate {
convertedValue = Array.get(convertedValue, 0);
standardConversion = true;
}
if (String.class.equals(requiredType) && ClassUtils.isPrimitiveOrWrapper(convertedValue.getClass())) {
if (String.class == requiredType && ClassUtils.isPrimitiveOrWrapper(convertedValue.getClass())) {
// We can stringify any primitive value...
return (T) convertedValue.toString();
}
@ -305,7 +305,7 @@ class TypeConverterDelegate {
}
if (conversionAttemptEx != null) {
if (editor == null && !standardConversion && requiredType != null && !Object.class.equals(requiredType)) {
if (editor == null && !standardConversion && requiredType != null && Object.class != requiredType) {
throw conversionAttemptEx;
}
logger.debug("Original ConversionService attempt failed - ignored since " +
@ -318,7 +318,7 @@ class TypeConverterDelegate {
private Object attemptToConvertStringToEnum(Class<?> requiredType, String trimmedValue, Object currentConvertedValue) {
Object convertedValue = currentConvertedValue;
if (Enum.class.equals(requiredType)) {
if (Enum.class == requiredType) {
// target type is declared as raw enum, treat the trimmed value as <enum.fqn>.FIELD_NAME
int index = trimmedValue.lastIndexOf(".");
if (index > - 1) {
@ -370,7 +370,7 @@ class TypeConverterDelegate {
if (requiredType != null) {
// No custom editor -> check BeanWrapperImpl's default editors.
editor = this.propertyEditorRegistry.getDefaultEditor(requiredType);
if (editor == null && !String.class.equals(requiredType)) {
if (editor == null && String.class != requiredType) {
// No BeanWrapper default editor -> check standard JavaBean editor.
editor = BeanUtils.findEditorByConvention(requiredType);
}
@ -436,7 +436,7 @@ class TypeConverterDelegate {
String newTextValue = (String) convertedValue;
return doConvertTextValue(oldValue, newTextValue, editor);
}
else if (String.class.equals(requiredType)) {
else if (String.class == requiredType) {
returnValue = convertedValue;
}
}

View File

@ -146,7 +146,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
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()) {
match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations());
}
}

View File

@ -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.
@ -314,7 +314,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
Class<?>[] paramTypes = exceptionConstructor.getParameterTypes();
Object[] args = new Object[paramTypes.length];
for (int i = 0; i < paramTypes.length; i++) {
if (paramTypes[i].equals(String.class)) {
if (String.class == paramTypes[i]) {
args[i] = cause.getMessage();
}
else if (paramTypes[i].isInstance(cause)) {
@ -409,7 +409,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
Class<?> serviceLocatorReturnType = interfaceMethod.getReturnType();
// Check whether the method is a valid service locator.
if (paramTypes.length > 1 || void.class.equals(serviceLocatorReturnType)) {
if (paramTypes.length > 1 || void.class == serviceLocatorReturnType) {
throw new UnsupportedOperationException(
"May only call methods with signature '<type> xxx()' or '<type> xxx(<idtype> id)' " +
"on factory interface, but tried to call: " + interfaceMethod);

View File

@ -603,7 +603,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
if (bp instanceof SmartInstantiationAwareBeanPostProcessor) {
SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor) bp;
Class<?> predicted = ibp.predictBeanType(targetType, beanName);
if (predicted != null && (typesToMatch.length != 1 || !FactoryBean.class.equals(typesToMatch[0]) ||
if (predicted != null && (typesToMatch.length != 1 || FactoryBean.class != typesToMatch[0] ||
FactoryBean.class.isAssignableFrom(predicted))) {
return predicted;
}
@ -779,7 +779,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
}
});
if (objectType.value != null && !Object.class.equals(objectType.value)) {
if (objectType.value != null && Object.class != objectType.value) {
return objectType.value;
}
}
@ -1284,7 +1284,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
PropertyDescriptor pd = bw.getPropertyDescriptor(propertyName);
// Don't try autowiring by type for type Object: never makes sense,
// even if it technically is a unsatisfied, non-simple property.
if (!Object.class.equals(pd.getPropertyType())) {
if (Object.class != pd.getPropertyType()) {
MethodParameter methodParam = BeanUtils.getWriteMethodParameter(pd);
// Do not allow eager init for type matching in case of a prioritized post-processor.
boolean eager = !PriorityOrdered.class.isAssignableFrom(bw.getWrappedClass());

View File

@ -516,7 +516,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
Class<?> classToMatch = typeToMatch.getRawClass();
Class<?>[] typesToMatch = (FactoryBean.class.equals(classToMatch) ?
Class<?>[] typesToMatch = (FactoryBean.class == classToMatch ?
new Class<?>[] {classToMatch} : new Class<?>[] {FactoryBean.class, classToMatch});
// Check decorated bean definition, if any: We assume it'll be easier

View File

@ -552,7 +552,7 @@ class ConstructorResolver {
"exists and that it is " +
(isStatic ? "static" : "non-static") + ".");
}
else if (void.class.equals(factoryMethodToUse.getReturnType())) {
else if (void.class == factoryMethodToUse.getReturnType()) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Invalid factory method '" + mbd.getFactoryMethodName() +
"': needs to have a non-void return type!");

View File

@ -949,10 +949,10 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
if (descriptor.getDependencyType().equals(javaUtilOptionalClass)) {
return new OptionalDependencyFactory().createOptionalDependency(descriptor, beanName);
}
else if (descriptor.getDependencyType().equals(ObjectFactory.class)) {
else if (ObjectFactory.class == descriptor.getDependencyType()) {
return new DependencyObjectFactory(descriptor, beanName);
}
else if (descriptor.getDependencyType().equals(javaxInjectProviderClass)) {
else if (javaxInjectProviderClass == descriptor.getDependencyType()) {
return new DependencyProviderFactory().createDependencyProvider(descriptor, beanName);
}
else {
@ -1031,10 +1031,10 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
else if (Map.class.isAssignableFrom(type) && type.isInterface()) {
Class<?> keyType = descriptor.getMapKeyType();
if (keyType == null || !String.class.isAssignableFrom(keyType)) {
if (String.class != keyType) {
if (descriptor.isRequired()) {
throw new FatalBeanException("Key type [" + keyType + "] of map [" + type.getName() +
"] must be assignable to [java.lang.String]");
"] must be [java.lang.String]");
}
return null;
}

View File

@ -130,7 +130,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
beanName + "' has more than one parameter - not supported as destroy method");
}
else if (paramTypes.length == 1 && !paramTypes[0].equals(boolean.class)) {
else if (paramTypes.length == 1 && boolean.class != paramTypes[0]) {
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
beanName + "' has a non-boolean parameter - not supported as destroy method");
}

View File

@ -159,10 +159,10 @@ public class CustomCollectionEditor extends PropertyEditorSupport {
"Could not instantiate collection class [" + collectionType.getName() + "]: " + ex.getMessage());
}
}
else if (List.class.equals(collectionType)) {
else if (List.class == collectionType) {
return new ArrayList<Object>(initialCapacity);
}
else if (SortedSet.class.equals(collectionType)) {
else if (SortedSet.class == collectionType) {
return new TreeSet<Object>();
}
else {

View File

@ -137,7 +137,7 @@ public class CustomMapEditor extends PropertyEditorSupport {
"Could not instantiate map class [" + mapType.getName() + "]: " + ex.getMessage());
}
}
else if (SortedMap.class.equals(mapType)) {
else if (SortedMap.class == mapType) {
return new TreeMap<Object, Object>();
}
else {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -160,10 +160,10 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
protected CacheResolverFactory determineCacheResolverFactory(CacheDefaults defaults,
Class<? extends CacheResolverFactory> candidate) {
if (!CacheResolverFactory.class.equals(candidate)) {
if (CacheResolverFactory.class != candidate) {
return getBean(candidate);
}
else if (defaults != null && !CacheResolverFactory.class.equals(defaults.cacheResolverFactory())) {
else if (defaults != null && CacheResolverFactory.class != defaults.cacheResolverFactory()) {
return getBean(defaults.cacheResolverFactory());
}
else {
@ -172,10 +172,10 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
}
protected KeyGenerator determineKeyGenerator(CacheDefaults defaults, Class<? extends CacheKeyGenerator> candidate) {
if (!CacheKeyGenerator.class.equals(candidate)) {
if (CacheKeyGenerator.class != candidate) {
return new KeyGeneratorAdapter(this, getBean(candidate));
}
else if (defaults != null && !CacheKeyGenerator.class.equals(defaults.cacheKeyGenerator())) {
else if (defaults != null && CacheKeyGenerator.class != defaults.cacheKeyGenerator()) {
return new KeyGeneratorAdapter(this, getBean(defaults.cacheKeyGenerator()));
}
else {

View File

@ -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 {

View File

@ -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);

View File

@ -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 {

View File

@ -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));

View File

@ -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;

View File

@ -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()));
}
}

View File

@ -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;

View File

@ -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");
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
}

View File

@ -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());
}
}

View File

@ -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");

View File

@ -141,7 +141,7 @@ public abstract class BridgeMethodResolver {
private static Method findGenericDeclaration(Method bridgeMethod) {
// Search parent types for method that has same signature as bridge.
Class<?> superclass = bridgeMethod.getDeclaringClass().getSuperclass();
while (superclass != null && !Object.class.equals(superclass)) {
while (superclass != null && Object.class != superclass) {
Method method = searchForMatch(superclass, bridgeMethod);
if (method != null && !method.isBridge()) {
return method;

View File

@ -178,20 +178,20 @@ public abstract class CollectionFactory {
public static <E> Collection<E> createCollection(Class<?> collectionType, Class<?> elementType, int capacity) {
Assert.notNull(collectionType, "Collection type must not be null");
if (collectionType.isInterface()) {
if (Set.class.equals(collectionType) || Collection.class.equals(collectionType)) {
if (Set.class == collectionType || Collection.class == collectionType) {
return new LinkedHashSet<E>(capacity);
}
else if (List.class.equals(collectionType)) {
else if (List.class == collectionType) {
return new ArrayList<E>(capacity);
}
else if (SortedSet.class.equals(collectionType) || NavigableSet.class.equals(collectionType)) {
else if (SortedSet.class == collectionType || NavigableSet.class == collectionType) {
return new TreeSet<E>();
}
else {
throw new IllegalArgumentException("Unsupported Collection interface: " + collectionType.getName());
}
}
else if (EnumSet.class.equals(collectionType)) {
else if (EnumSet.class == collectionType) {
Assert.notNull(elementType, "Cannot create EnumSet for unknown element type");
// Cast is necessary for compilation in Eclipse 4.4.1.
return (Collection<E>) EnumSet.noneOf(asEnumType(elementType));
@ -294,20 +294,20 @@ public abstract class CollectionFactory {
public static <K, V> Map<K, V> createMap(Class<?> mapType, Class<?> keyType, int capacity) {
Assert.notNull(mapType, "Map type must not be null");
if (mapType.isInterface()) {
if (Map.class.equals(mapType)) {
if (Map.class == mapType) {
return new LinkedHashMap<K, V>(capacity);
}
else if (SortedMap.class.equals(mapType) || NavigableMap.class.equals(mapType)) {
else if (SortedMap.class == mapType || NavigableMap.class == mapType) {
return new TreeMap<K, V>();
}
else if (MultiValueMap.class.equals(mapType)) {
else if (MultiValueMap.class == mapType) {
return new LinkedMultiValueMap();
}
else {
throw new IllegalArgumentException("Unsupported Map interface: " + mapType.getName());
}
}
else if (EnumMap.class.equals(mapType)) {
else if (EnumMap.class == mapType) {
Assert.notNull(keyType, "Cannot create EnumMap for unknown key type");
return new EnumMap(asEnumType(keyType));
}

View File

@ -168,7 +168,7 @@ public abstract class Conventions {
public static String getVariableNameForReturnType(Method method, Class<?> resolvedType, Object value) {
Assert.notNull(method, "Method must not be null");
if (Object.class.equals(resolvedType)) {
if (Object.class == resolvedType) {
if (value == null) {
throw new IllegalArgumentException("Cannot generate variable name for an Object return type with null value");
}

View File

@ -63,12 +63,12 @@ public class ExceptionDepthComparator implements Comparator<Class<? extends Thro
}
private int getDepth(Class<?> declaredException, Class<?> exceptionToMatch, int depth) {
if (declaredException.equals(exceptionToMatch)) {
if (exceptionToMatch.equals(declaredException)) {
// Found it!
return depth;
}
// If we've gone as far as we can go and haven't found it...
if (Throwable.class.equals(exceptionToMatch)) {
if (exceptionToMatch == Throwable.class) {
return Integer.MAX_VALUE;
}
return getDepth(declaredException, exceptionToMatch.getSuperclass(), depth + 1);

View File

@ -77,10 +77,10 @@ public abstract class ParameterizedTypeReference<T> {
private static Class<?> findParameterizedTypeReferenceSubclass(Class<?> child) {
Class<?> parent = child.getSuperclass();
if (Object.class.equals(parent)) {
if (Object.class == parent) {
throw new IllegalStateException("Expected ParameterizedTypeReference superclass");
}
else if (ParameterizedTypeReference.class.equals(parent)) {
else if (ParameterizedTypeReference.class == parent) {
return child;
}
else {

View File

@ -527,7 +527,7 @@ public class ResolvableType implements Serializable {
WildcardType wt = (WildcardType) this.type;
if (wt.getLowerBounds().length == 0) {
Type[] upperBounds = wt.getUpperBounds();
if (upperBounds.length == 0 || (upperBounds.length == 1 && Object.class.equals(upperBounds[0]))) {
if (upperBounds.length == 0 || (upperBounds.length == 1 && Object.class == upperBounds[0])) {
return true;
}
}
@ -770,7 +770,7 @@ public class ResolvableType implements Serializable {
}
private Type resolveBounds(Type[] bounds) {
if (ObjectUtils.isEmpty(bounds) || Object.class.equals(bounds[0])) {
if (ObjectUtils.isEmpty(bounds) || Object.class == bounds[0]) {
return null;
}
return bounds[0];

View File

@ -244,10 +244,10 @@ abstract class SerializableTypeWrapper {
}
return this.provider.getType().equals(other);
}
if (Type.class.equals(method.getReturnType()) && args == null) {
if (Type.class == method.getReturnType() && args == null) {
return forTypeProvider(new MethodInvokeTypeProvider(this.provider, method, -1));
}
if (Type[].class.equals(method.getReturnType()) && args == null) {
if (Type[].class == method.getReturnType() && args == null) {
Type[] result = new Type[((Type[]) method.invoke(this.provider.getType(), args)).length];
for (int i = 0; i < result.length; i++) {
result[i] = forTypeProvider(new MethodInvokeTypeProvider(this.provider, method, i));

View File

@ -694,7 +694,7 @@ public class AnnotatedElementUtils {
Class<?> clazz = method.getDeclaringClass();
while (true) {
clazz = clazz.getSuperclass();
if (clazz == null || clazz.equals(Object.class)) {
if (clazz == null || Object.class == clazz) {
break;
}
@ -744,7 +744,7 @@ public class AnnotatedElementUtils {
// Search on superclass
if (searchOnSuperclasses) {
Class<?> superclass = clazz.getSuperclass();
if (superclass != null && !superclass.equals(Object.class)) {
if (superclass != null && Object.class != superclass) {
T result = searchWithFindSemantics(superclass, annotationType, searchOnInterfaces,
searchOnSuperclasses, searchOnMethodsInInterfaces, searchOnMethodsInSuperclasses,
processor, visited, metaDepth);

View File

@ -368,7 +368,7 @@ public abstract class AnnotationUtils {
Class<?> clazz = method.getDeclaringClass();
while (result == null) {
clazz = clazz.getSuperclass();
if (clazz == null || clazz.equals(Object.class)) {
if (clazz == null || Object.class == clazz) {
break;
}
try {
@ -511,7 +511,7 @@ public abstract class AnnotationUtils {
}
Class<?> superclass = clazz.getSuperclass();
if (superclass == null || superclass.equals(Object.class)) {
if (superclass == null || Object.class == superclass) {
return null;
}
return findAnnotation(superclass, annotationType, visited);
@ -541,7 +541,7 @@ public abstract class AnnotationUtils {
*/
public static Class<?> findAnnotationDeclaringClass(Class<? extends Annotation> annotationType, Class<?> clazz) {
Assert.notNull(annotationType, "Annotation type must not be null");
if (clazz == null || clazz.equals(Object.class)) {
if (clazz == null || Object.class == clazz) {
return null;
}
if (isAnnotationDeclaredLocally(annotationType, clazz)) {
@ -576,7 +576,7 @@ public abstract class AnnotationUtils {
*/
public static Class<?> findAnnotationDeclaringClassForTypes(List<Class<? extends Annotation>> annotationTypes, Class<?> clazz) {
Assert.notEmpty(annotationTypes, "The list of annotation types must not be empty");
if (clazz == null || clazz.equals(Object.class)) {
if (clazz == null || Object.class == clazz) {
return null;
}
for (Class<? extends Annotation> annotationType : annotationTypes) {

View File

@ -677,7 +677,7 @@ public class TypeDescriptor implements Serializable {
private static TypeDescriptor nested(TypeDescriptor typeDescriptor, int nestingLevel) {
ResolvableType nested = typeDescriptor.resolvableType;
for (int i = 0; i < nestingLevel; i++) {
if (Object.class.equals(nested.getType())) {
if (Object.class == nested.getType()) {
// Could be a collection type but we don't know about its element type,
// so let's just assume there is an element type of type Object...
}

View File

@ -50,7 +50,7 @@ final class FallbackObjectToStringConverter implements ConditionalGenericConvert
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
Class<?> sourceClass = sourceType.getObjectType();
if (String.class.equals(sourceClass)) {
if (String.class == sourceClass) {
// no conversion required
return false;
}

View File

@ -71,7 +71,7 @@ final class ObjectToObjectConverter implements ConditionalGenericConverter {
// no conversion required
return false;
}
return (String.class.equals(targetType.getType()) ?
return (String.class == targetType.getType() ?
hasFactoryConstructor(String.class, sourceType.getType()) :
hasToMethodOrFactoryMethodOrConstructor(targetType.getType(), sourceType.getType()));
}
@ -85,7 +85,7 @@ final class ObjectToObjectConverter implements ConditionalGenericConverter {
Class<?> targetClass = targetType.getType();
try {
// Do not invoke a toString() method
if (!String.class.equals(targetClass)) {
if (String.class != targetClass) {
Method method = getToMethod(targetClass, sourceClass);
if (method != null) {
ReflectionUtils.makeAccessible(method);

View File

@ -759,7 +759,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
if (Object.class.equals(method.getDeclaringClass())) {
if (Object.class == method.getDeclaringClass()) {
if (methodName.equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0]);

View File

@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
@ -34,7 +35,7 @@ import java.util.Set;
/**
* Miscellaneous class utility methods.
* <p>Mainly for internal use within the framework.
* Mainly for internal use within the framework.
*
* @author Juergen Hoeller
* @author Keith Donald
@ -75,13 +76,13 @@ public abstract class ClassUtils {
* Map with primitive wrapper type as key and corresponding primitive
* type as value, for example: Integer.class -> int.class.
*/
private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new HashMap<Class<?>, Class<?>>(8);
private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new IdentityHashMap<Class<?>, Class<?>>(8);
/**
* Map with primitive type as key and corresponding wrapper
* type as value, for example: int.class -> Integer.class.
*/
private static final Map<Class<?>, Class<?>> primitiveTypeToWrapperMap = new HashMap<Class<?>, Class<?>>(8);
private static final Map<Class<?>, Class<?>> primitiveTypeToWrapperMap = new IdentityHashMap<Class<?>, Class<?>>(8);
/**
* Map with primitive type name as key and corresponding primitive
@ -352,9 +353,9 @@ public abstract class ClassUtils {
*/
public static Class<?> getUserClass(Class<?> clazz) {
if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
Class<?> superClass = clazz.getSuperclass();
if (superClass != null && !Object.class.equals(superClass)) {
return superClass;
Class<?> superclass = clazz.getSuperclass();
if (superclass != null && Object.class != superclass) {
return superclass;
}
}
return clazz;
@ -1186,7 +1187,7 @@ public abstract class ClassUtils {
Class<?> ancestor = clazz1;
do {
ancestor = ancestor.getSuperclass();
if (ancestor == null || Object.class.equals(ancestor)) {
if (ancestor == null || Object.class == ancestor) {
return null;
}
}

View File

@ -86,28 +86,28 @@ public abstract class NumberUtils {
if (targetClass.isInstance(number)) {
return (T) number;
}
else if (targetClass.equals(Byte.class)) {
else if (Byte.class == targetClass) {
long value = number.longValue();
if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
raiseOverflowException(number, targetClass);
}
return (T) new Byte(number.byteValue());
}
else if (targetClass.equals(Short.class)) {
else if (Short.class == targetClass) {
long value = number.longValue();
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
raiseOverflowException(number, targetClass);
}
return (T) new Short(number.shortValue());
}
else if (targetClass.equals(Integer.class)) {
else if (Integer.class == targetClass) {
long value = number.longValue();
if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
raiseOverflowException(number, targetClass);
}
return (T) new Integer(number.intValue());
}
else if (targetClass.equals(Long.class)) {
else if (Long.class == targetClass) {
BigInteger bigInt = null;
if (number instanceof BigInteger) {
bigInt = (BigInteger) number;
@ -121,7 +121,7 @@ public abstract class NumberUtils {
}
return (T) new Long(number.longValue());
}
else if (targetClass.equals(BigInteger.class)) {
else if (BigInteger.class == targetClass) {
if (number instanceof BigDecimal) {
// do not lose precision - use BigDecimal's own conversion
return (T) ((BigDecimal) number).toBigInteger();
@ -131,13 +131,13 @@ public abstract class NumberUtils {
return (T) BigInteger.valueOf(number.longValue());
}
}
else if (targetClass.equals(Float.class)) {
else if (Float.class == targetClass) {
return (T) new Float(number.floatValue());
}
else if (targetClass.equals(Double.class)) {
else if (Double.class == targetClass) {
return (T) new Double(number.doubleValue());
}
else if (targetClass.equals(BigDecimal.class)) {
else if (BigDecimal.class == targetClass) {
// always use BigDecimal(String) here to avoid unpredictability of BigDecimal(double)
// (see BigDecimal javadoc for details)
return (T) new BigDecimal(number.toString());
@ -183,28 +183,28 @@ public abstract class NumberUtils {
Assert.notNull(targetClass, "Target class must not be null");
String trimmed = StringUtils.trimAllWhitespace(text);
if (targetClass.equals(Byte.class)) {
if (Byte.class == targetClass) {
return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
}
else if (targetClass.equals(Short.class)) {
else if (Short.class == targetClass) {
return (T) (isHexNumber(trimmed) ? Short.decode(trimmed) : Short.valueOf(trimmed));
}
else if (targetClass.equals(Integer.class)) {
else if (Integer.class == targetClass) {
return (T) (isHexNumber(trimmed) ? Integer.decode(trimmed) : Integer.valueOf(trimmed));
}
else if (targetClass.equals(Long.class)) {
else if (Long.class == targetClass) {
return (T) (isHexNumber(trimmed) ? Long.decode(trimmed) : Long.valueOf(trimmed));
}
else if (targetClass.equals(BigInteger.class)) {
else if (BigInteger.class == targetClass) {
return (T) (isHexNumber(trimmed) ? decodeBigInteger(trimmed) : new BigInteger(trimmed));
}
else if (targetClass.equals(Float.class)) {
else if (Float.class == targetClass) {
return (T) Float.valueOf(trimmed);
}
else if (targetClass.equals(Double.class)) {
else if (Double.class == targetClass) {
return (T) Double.valueOf(trimmed);
}
else if (targetClass.equals(BigDecimal.class) || targetClass.equals(Number.class)) {
else if (BigDecimal.class == targetClass || Number.class == targetClass) {
return (T) new BigDecimal(trimmed);
}
else {
@ -236,7 +236,7 @@ public abstract class NumberUtils {
boolean resetBigDecimal = false;
if (numberFormat instanceof DecimalFormat) {
decimalFormat = (DecimalFormat) numberFormat;
if (BigDecimal.class.equals(targetClass) && !decimalFormat.isParseBigDecimal()) {
if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) {
decimalFormat.setParseBigDecimal(true);
resetBigDecimal = true;
}

View File

@ -89,7 +89,7 @@ public abstract class ReflectionUtils {
Assert.notNull(clazz, "Class must not be null");
Assert.isTrue(name != null || type != null, "Either name or type of the field must be specified");
Class<?> searchType = clazz;
while (!Object.class.equals(searchType) && searchType != null) {
while (Object.class != searchType && searchType != null) {
Field[] fields = getDeclaredFields(searchType);
for (Field field : fields) {
if ((name == null || name.equals(field.getName())) &&

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@ -44,7 +44,7 @@ public abstract class TypeUtils {
Assert.notNull(rhsType, "Right-hand side type must not be null");
// all types are assignable to themselves and to class Object
if (lhsType.equals(rhsType) || lhsType.equals(Object.class)) {
if (lhsType.equals(rhsType) || Object.class == lhsType) {
return true;
}

View File

@ -166,7 +166,7 @@ public class Indexer extends SpelNodeImpl {
// Try and treat the index value as a property of the context object
// TODO could call the conversion service to convert the value to a String
if (String.class.equals(indexValue.getTypeDescriptor().getType())) {
if (String.class == indexValue.getTypeDescriptor().getType()) {
this.indexedType = IndexedType.OBJECT;
return new PropertyIndexingValueRef(targetObject, (String) indexValue.getValue(),
state.getEvaluationContext(), targetDescriptor);

View File

@ -97,43 +97,40 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
if (result.getValue() == null && isAutoGrowNullReferences &&
nextChildIs(Indexer.class, PropertyOrFieldReference.class)) {
TypeDescriptor resultDescriptor = result.getTypeDescriptor();
// Creating lists and maps
if ((resultDescriptor.getType().equals(List.class) || resultDescriptor.getType().equals(Map.class))) {
// Create a new collection or map ready for the indexer
if (resultDescriptor.getType().equals(List.class)) {
try {
if (isWritableProperty(this.name, contextObject, evalContext)) {
List<?> newList = ArrayList.class.newInstance();
writeProperty(contextObject, evalContext, this.name, newList);
result = readProperty(contextObject, evalContext, this.name);
}
}
catch (InstantiationException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
}
catch (IllegalAccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
// Create a new collection or map ready for the indexer
if (List.class == resultDescriptor.getType()) {
try {
if (isWritableProperty(this.name, contextObject, evalContext)) {
List<?> newList = ArrayList.class.newInstance();
writeProperty(contextObject, evalContext, this.name, newList);
result = readProperty(contextObject, evalContext, this.name);
}
}
else {
try {
if (isWritableProperty(this.name,contextObject, evalContext)) {
Map<?,?> newMap = HashMap.class.newInstance();
writeProperty(contextObject, evalContext, this.name, newMap);
result = readProperty(contextObject, evalContext, this.name);
}
}
catch (InstantiationException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
}
catch (IllegalAccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
catch (InstantiationException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
}
catch (IllegalAccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
}
}
else if (Map.class == resultDescriptor.getType()) {
try {
if (isWritableProperty(this.name,contextObject, evalContext)) {
Map<?,?> newMap = HashMap.class.newInstance();
writeProperty(contextObject, evalContext, this.name, newMap);
result = readProperty(contextObject, evalContext, this.name);
}
}
catch (InstantiationException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
}
catch (IllegalAccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
}
}
else {
// 'simple' object

View File

@ -165,7 +165,7 @@ public class SingleColumnRowMapper<T> implements RowMapper<T> {
*/
@SuppressWarnings("unchecked")
protected Object convertValueToRequiredType(Object value, Class<?> requiredType) {
if (String.class.equals(requiredType)) {
if (String.class == requiredType) {
return value.toString();
}
else if (Number.class.isAssignableFrom(requiredType)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -144,50 +144,50 @@ public abstract class JdbcUtils {
Object value;
// Explicitly extract typed value, as far as possible.
if (String.class.equals(requiredType)) {
if (String.class == requiredType) {
return rs.getString(index);
}
else if (boolean.class.equals(requiredType) || Boolean.class.equals(requiredType)) {
else if (boolean.class == requiredType || Boolean.class == requiredType) {
value = rs.getBoolean(index);
}
else if (byte.class.equals(requiredType) || Byte.class.equals(requiredType)) {
else if (byte.class == requiredType || Byte.class == requiredType) {
value = rs.getByte(index);
}
else if (short.class.equals(requiredType) || Short.class.equals(requiredType)) {
else if (short.class == requiredType || Short.class == requiredType) {
value = rs.getShort(index);
}
else if (int.class.equals(requiredType) || Integer.class.equals(requiredType)) {
else if (int.class == requiredType || Integer.class == requiredType) {
value = rs.getInt(index);
}
else if (long.class.equals(requiredType) || Long.class.equals(requiredType)) {
else if (long.class == requiredType || Long.class == requiredType) {
value = rs.getLong(index);
}
else if (float.class.equals(requiredType) || Float.class.equals(requiredType)) {
else if (float.class == requiredType || Float.class == requiredType) {
value = rs.getFloat(index);
}
else if (double.class.equals(requiredType) || Double.class.equals(requiredType) ||
Number.class.equals(requiredType)) {
else if (double.class == requiredType || Double.class == requiredType ||
Number.class == requiredType) {
value = rs.getDouble(index);
}
else if (BigDecimal.class.equals(requiredType)) {
else if (BigDecimal.class == requiredType) {
return rs.getBigDecimal(index);
}
else if (java.sql.Date.class.equals(requiredType)) {
else if (java.sql.Date.class == requiredType) {
return rs.getDate(index);
}
else if (java.sql.Time.class.equals(requiredType)) {
else if (java.sql.Time.class == requiredType) {
return rs.getTime(index);
}
else if (java.sql.Timestamp.class.equals(requiredType) || java.util.Date.class.equals(requiredType)) {
else if (java.sql.Timestamp.class == requiredType || java.util.Date.class == requiredType) {
return rs.getTimestamp(index);
}
else if (byte[].class.equals(requiredType)) {
else if (byte[].class == requiredType) {
return rs.getBytes(index);
}
else if (Blob.class.equals(requiredType)) {
else if (Blob.class == requiredType) {
return rs.getBlob(index);
}
else if (Clob.class.equals(requiredType)) {
else if (Clob.class == requiredType) {
return rs.getClob(index);
}
else {

View File

@ -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.
@ -321,27 +321,27 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
Constructor<?>[] constructors = exceptionClass.getConstructors();
for (Constructor<?> constructor : constructors) {
Class<?>[] parameterTypes = constructor.getParameterTypes();
if (parameterTypes.length == 1 && parameterTypes[0].equals(String.class)) {
if (parameterTypes.length == 1 && String.class == parameterTypes[0]) {
if (constructorType < MESSAGE_ONLY_CONSTRUCTOR)
constructorType = MESSAGE_ONLY_CONSTRUCTOR;
}
if (parameterTypes.length == 2 && parameterTypes[0].equals(String.class) &&
parameterTypes[1].equals(Throwable.class)) {
if (parameterTypes.length == 2 && String.class == parameterTypes[0] &&
Throwable.class == parameterTypes[1]) {
if (constructorType < MESSAGE_THROWABLE_CONSTRUCTOR)
constructorType = MESSAGE_THROWABLE_CONSTRUCTOR;
}
if (parameterTypes.length == 2 && parameterTypes[0].equals(String.class) &&
parameterTypes[1].equals(SQLException.class)) {
if (parameterTypes.length == 2 && String.class == parameterTypes[0] &&
SQLException.class == parameterTypes[1]) {
if (constructorType < MESSAGE_SQLEX_CONSTRUCTOR)
constructorType = MESSAGE_SQLEX_CONSTRUCTOR;
}
if (parameterTypes.length == 3 && parameterTypes[0].equals(String.class) &&
parameterTypes[1].equals(String.class) && parameterTypes[2].equals(Throwable.class)) {
if (parameterTypes.length == 3 && String.class == parameterTypes[0] &&
String.class == parameterTypes[1] && Throwable.class == parameterTypes[2]) {
if (constructorType < MESSAGE_SQL_THROWABLE_CONSTRUCTOR)
constructorType = MESSAGE_SQL_THROWABLE_CONSTRUCTOR;
}
if (parameterTypes.length == 3 && parameterTypes[0].equals(String.class) &&
parameterTypes[1].equals(String.class) && parameterTypes[2].equals(SQLException.class)) {
if (parameterTypes.length == 3 && String.class == parameterTypes[0] &&
String.class == parameterTypes[1] && SQLException.class == parameterTypes[2]) {
if (constructorType < MESSAGE_SQL_SQLEX_CONSTRUCTOR)
constructorType = MESSAGE_SQL_SQLEX_CONSTRUCTOR;
}

View File

@ -234,14 +234,14 @@ public class TransactionAwareConnectionFactoryProxy
// Use hashCode of Connection proxy.
return System.identityHashCode(proxy);
}
else if (Session.class.equals(method.getReturnType())) {
else if (Session.class == method.getReturnType()) {
Session session = ConnectionFactoryUtils.getTransactionalSession(
getTargetConnectionFactory(), this.target, isSynchedLocalTransactionAllowed());
if (session != null) {
return getCloseSuppressingSessionProxy(session);
}
}
else if (QueueSession.class.equals(method.getReturnType())) {
else if (QueueSession.class == method.getReturnType()) {
QueueSession session = ConnectionFactoryUtils.getTransactionalQueueSession(
(QueueConnectionFactory) getTargetConnectionFactory(), (QueueConnection) this.target,
isSynchedLocalTransactionAllowed());
@ -249,7 +249,7 @@ public class TransactionAwareConnectionFactoryProxy
return getCloseSuppressingSessionProxy(session);
}
}
else if (TopicSession.class.equals(method.getReturnType())) {
else if (TopicSession.class == method.getReturnType()) {
TopicSession session = ConnectionFactoryUtils.getTransactionalTopicSession(
(TopicConnectionFactory) getTargetConnectionFactory(), (TopicConnection) this.target,
isSynchedLocalTransactionAllowed());

View File

@ -146,7 +146,7 @@ public abstract class AbstractMessageConverter implements MessageConverter {
* @param payloadClass either byte[] or String
*/
public void setSerializedPayloadClass(Class<?> payloadClass) {
Assert.isTrue(byte[].class.equals(payloadClass) || String.class.equals(payloadClass),
Assert.isTrue(byte[].class == payloadClass || String.class == payloadClass,
"Payload class must be byte[] or String: " + payloadClass);
this.serializedPayloadClass = payloadClass;
}

View File

@ -37,7 +37,7 @@ public class ByteArrayMessageConverter extends AbstractMessageConverter {
@Override
protected boolean supports(Class<?> clazz) {
return byte[].class.equals(clazz);
return byte[].class == clazz;
}
@Override

View File

@ -215,7 +215,7 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
public Object convertToInternal(Object payload, MessageHeaders headers) {
try {
Class<?> serializationView = getSerializationView(headers);
if (byte[].class.equals(getSerializedPayloadClass())) {
if (byte[].class == getSerializedPayloadClass()) {
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
JsonEncoding encoding = getJsonEncoding(getMimeType(headers));
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(out, encoding);

View File

@ -172,7 +172,7 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
public Object convertToInternal(Object payload, MessageHeaders headers) {
Assert.notNull(this.marshaller, "Property 'marshaller' is required");
try {
if (byte[].class.equals(getSerializedPayloadClass())) {
if (byte[].class == getSerializedPayloadClass()) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Result result = new StreamResult(out);

View File

@ -46,7 +46,7 @@ public class StringMessageConverter extends AbstractMessageConverter {
@Override
protected boolean supports(Class<?> clazz) {
return String.class.equals(clazz);
return String.class == clazz;
}
@Override
@ -58,7 +58,7 @@ public class StringMessageConverter extends AbstractMessageConverter {
@Override
public Object convertToInternal(Object payload, MessageHeaders headers) {
if (byte[].class.equals(getSerializedPayloadClass())) {
if (byte[].class == getSerializedPayloadClass()) {
Charset charset = getContentTypeCharset(getMimeType(headers));
payload = ((String) payload).getBytes(charset);
}

View File

@ -46,7 +46,7 @@ public class HeadersMethodArgumentResolver implements HandlerMethodArgumentResol
public boolean supportsParameter(MethodParameter parameter) {
Class<?> paramType = parameter.getParameterType();
return ((parameter.hasParameterAnnotation(Headers.class) && Map.class.isAssignableFrom(paramType)) ||
MessageHeaders.class.equals(paramType) ||
MessageHeaders.class == paramType ||
MessageHeaderAccessor.class.isAssignableFrom(paramType));
}
@ -58,7 +58,7 @@ public class HeadersMethodArgumentResolver implements HandlerMethodArgumentResol
if (Map.class.isAssignableFrom(paramType)) {
return message.getHeaders();
}
else if (MessageHeaderAccessor.class.equals(paramType)) {
else if (MessageHeaderAccessor.class == paramType) {
MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
return (accessor != null ? accessor : new MessageHeaderAccessor(message));
}

View File

@ -459,7 +459,7 @@ public abstract class AbstractMethodMessageHandler<T>
try {
Object returnValue = invocable.invoke(message);
MethodParameter returnType = handlerMethod.getReturnType();
if (void.class.equals(returnType.getParameterType())) {
if (void.class == returnType.getParameterType()) {
return;
}
this.returnValueHandlers.handleReturnValue(returnValue, returnType, message);
@ -485,7 +485,7 @@ public abstract class AbstractMethodMessageHandler<T>
try {
Object returnValue = invocable.invoke(message, ex);
MethodParameter returnType = invocable.getReturnType();
if (void.class.equals(returnType.getParameterType())) {
if (void.class == returnType.getParameterType()) {
return;
}
this.returnValueHandlers.handleReturnValue(returnValue, returnType, message);

View File

@ -408,7 +408,7 @@ public abstract class HibernateAccessor implements InitializingBean, BeanFactory
if (getJdbcExceptionTranslator() != null && ex instanceof JDBCException) {
return convertJdbcAccessException((JDBCException) ex, getJdbcExceptionTranslator());
}
else if (GenericJDBCException.class.equals(ex.getClass())) {
else if (GenericJDBCException.class == ex.getClass()) {
return convertJdbcAccessException((GenericJDBCException) ex, getDefaultJdbcExceptionTranslator());
}
return SessionFactoryUtils.convertHibernateAccessException(ex);

View File

@ -794,7 +794,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
if (getJdbcExceptionTranslator() != null && ex instanceof JDBCException) {
return convertJdbcAccessException((JDBCException) ex, getJdbcExceptionTranslator());
}
else if (GenericJDBCException.class.equals(ex.getClass())) {
else if (GenericJDBCException.class == ex.getClass()) {
return convertJdbcAccessException((GenericJDBCException) ex, getDefaultJdbcExceptionTranslator());
}
return SessionFactoryUtils.convertHibernateAccessException(ex);

View File

@ -557,7 +557,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
public boolean supports(Type genericType) {
if (genericType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) genericType;
if (JAXBElement.class.equals(parameterizedType.getRawType()) &&
if (JAXBElement.class == parameterizedType.getRawType() &&
parameterizedType.getActualTypeArguments().length == 1) {
Type typeArgument = parameterizedType.getActualTypeArguments()[0];
if (typeArgument instanceof Class) {
@ -610,13 +610,13 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
* Compare section 8.5.1 of the JAXB2 spec.
*/
private boolean isPrimitiveWrapper(Class<?> clazz) {
return Boolean.class.equals(clazz) ||
Byte.class.equals(clazz) ||
Short.class.equals(clazz) ||
Integer.class.equals(clazz) ||
Long.class.equals(clazz) ||
Float.class.equals(clazz) ||
Double.class.equals(clazz);
return Boolean.class == clazz ||
Byte.class == clazz ||
Short.class == clazz ||
Integer.class == clazz ||
Long.class == clazz ||
Float.class == clazz ||
Double.class == clazz;
}
/**
@ -624,20 +624,20 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
* Compare section 8.5.2 of the JAXB2 spec.
*/
private boolean isStandardClass(Class<?> clazz) {
return String.class.equals(clazz) ||
return String.class == clazz ||
BigInteger.class.isAssignableFrom(clazz) ||
BigDecimal.class.isAssignableFrom(clazz) ||
Calendar.class.isAssignableFrom(clazz) ||
Date.class.isAssignableFrom(clazz) ||
QName.class.isAssignableFrom(clazz) ||
URI.class.equals(clazz) ||
URI.class == clazz ||
XMLGregorianCalendar.class.isAssignableFrom(clazz) ||
Duration.class.isAssignableFrom(clazz) ||
Image.class.equals(clazz) ||
DataHandler.class.equals(clazz) ||
Image.class == clazz ||
DataHandler.class == clazz ||
// Source and subclasses should be supported according to the JAXB2 spec, but aren't in the RI
// Source.class.isAssignableFrom(clazz) ||
UUID.class.equals(clazz);
UUID.class == clazz;
}

View File

@ -85,7 +85,7 @@ public abstract class ProfileValueUtils {
}
ProfileValueSource profileValueSource;
if (SystemProfileValueSource.class.equals(profileValueSourceType)) {
if (SystemProfileValueSource.class == profileValueSourceType) {
profileValueSource = SystemProfileValueSource.getInstance();
}
else {

View File

@ -463,7 +463,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
configAttributes));
}
Class<? extends ContextLoader> contextLoaderClass = configAttributes.getContextLoaderClass();
if (!ContextLoader.class.equals(contextLoaderClass)) {
if (ContextLoader.class != contextLoaderClass) {
if (logger.isDebugEnabled()) {
logger.debug(String.format(
"Found explicit ContextLoader class [%s] for context configuration attributes %s",
@ -480,10 +480,9 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
* interaction with the {@code ContextCache}.
* <p>The default implementation simply delegates to
* {@code getBootstrapContext().getCacheAwareContextLoaderDelegate()}.
* <p>Concrete subclasses may choose to override this method to return a
* custom {@code CacheAwareContextLoaderDelegate} implementation with custom
* {@link org.springframework.test.context.cache.ContextCache ContextCache}
* support.
* <p>Concrete subclasses may choose to override this method to return a custom
* {@code CacheAwareContextLoaderDelegate} implementation with custom
* {@link org.springframework.test.context.cache.ContextCache ContextCache} support.
* @return the context loader delegate (never {@code null})
*/
protected CacheAwareContextLoaderDelegate getCacheAwareContextLoaderDelegate() {
@ -509,10 +508,8 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
* <p>The default implementation simply returns the supplied instance unmodified.
* <p>Concrete subclasses may choose to return a specialized subclass of
* {@link MergedContextConfiguration} based on properties in the supplied instance.
* @param mergedConfig the {@code MergedContextConfiguration} to process;
* never {@code null}
* @return a fully initialized {@code MergedContextConfiguration}; never
* {@code null}
* @param mergedConfig the {@code MergedContextConfiguration} to process; never {@code null}
* @return a fully initialized {@code MergedContextConfiguration}; never {@code null}
*/
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
return mergedConfig;

View File

@ -97,7 +97,7 @@ abstract class ActiveProfilesUtils {
validateActiveProfilesConfiguration(declaringClass, annAttrs);
Class<? extends ActiveProfilesResolver> resolverClass = annAttrs.getClass("resolver");
if (ActiveProfilesResolver.class.equals(resolverClass)) {
if (ActiveProfilesResolver.class == resolverClass) {
resolverClass = DefaultActiveProfilesResolver.class;
}

View File

@ -410,7 +410,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
private List<Class<?>> getSuperClasses(Class<?> clazz) {
List<Class<?>> results = new ArrayList<Class<?>>();
Class<?> current = clazz;
while (current != null && !current.equals(Object.class)) {
while (current != null && Object.class != current) {
results.add(current);
current = current.getSuperclass();
}

View File

@ -52,7 +52,7 @@ public class JsonPathExpectationsHelper {
for (Method candidate : JsonPath.class.getMethods()) {
if (candidate.getName().equals("compile")) {
Class<?>[] paramTypes = candidate.getParameterTypes();
if (paramTypes.length == 2 && paramTypes[0].equals(String.class) && paramTypes[1].isArray()) {
if (paramTypes.length == 2 && String.class == paramTypes[0] && paramTypes[1].isArray()) {
compileMethod = candidate;
emptyFilters = Array.newInstance(paramTypes[1].getComponentType(), 0);
break;

View File

@ -103,7 +103,7 @@ public abstract class MetaAnnotationUtils {
Assert.notNull(annotationType, "Annotation type must not be null");
if (clazz == null || clazz.equals(Object.class)) {
if (clazz == null || Object.class == clazz) {
return null;
}
@ -181,7 +181,7 @@ public abstract class MetaAnnotationUtils {
Set<Annotation> visited, Class<? extends Annotation>... annotationTypes) {
assertNonEmptyAnnotationTypeArray(annotationTypes, "The list of annotation types must not be empty");
if (clazz == null || clazz.equals(Object.class)) {
if (clazz == null || Object.class == clazz) {
return null;
}

View File

@ -139,7 +139,7 @@ public abstract class DataAccessUtils {
Object result = requiredUniqueResult(results);
if (requiredType != null && !requiredType.isInstance(result)) {
if (String.class.equals(requiredType)) {
if (String.class == requiredType) {
result = result.toString();
}
else if (Number.class.isAssignableFrom(requiredType) && Number.class.isInstance(result)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -116,7 +116,7 @@ public class RollbackRuleAttribute implements Serializable{
return depth;
}
// If we've gone as far as we can go and haven't found it...
if (exceptionClass.equals(Throwable.class)) {
if (exceptionClass == Throwable.class) {
return -1;
}
return getDepth(exceptionClass.getSuperclass(), depth + 1);

View File

@ -129,7 +129,7 @@ public class BufferedImageHttpMessageConverter implements HttpMessageConverter<B
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
return (BufferedImage.class.equals(clazz) && isReadable(mediaType));
return (BufferedImage.class == clazz && isReadable(mediaType));
}
private boolean isReadable(MediaType mediaType) {
@ -142,7 +142,7 @@ public class BufferedImageHttpMessageConverter implements HttpMessageConverter<B
@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
return (BufferedImage.class.equals(clazz) && isWritable(mediaType));
return (BufferedImage.class == clazz && isWritable(mediaType));
}
private boolean isWritable(MediaType mediaType) {

View File

@ -43,7 +43,7 @@ public class ByteArrayHttpMessageConverter extends AbstractHttpMessageConverter<
@Override
public boolean supports(Class<?> clazz) {
return byte[].class.equals(clazz);
return byte[].class == clazz;
}
@Override

View File

@ -80,7 +80,7 @@ public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter<R
protected Long getContentLength(Resource resource, MediaType contentType) throws IOException {
// Don't try to determine contentLength on InputStreamResource - cannot be read afterwards...
// Note: custom InputStreamResource subclasses could provide a pre-calculated content length!
return (InputStreamResource.class.equals(resource.getClass()) ? null : resource.contentLength());
return (InputStreamResource.class == resource.getClass() ? null : resource.contentLength());
}
@Override

View File

@ -79,7 +79,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
@Override
public boolean supports(Class<?> clazz) {
return String.class.equals(clazz);
return String.class == clazz;
}
@Override

View File

@ -182,10 +182,10 @@ public class Jaxb2CollectionHttpMessageConverter<T extends Collection>
collectionClass.getName() + "]: " + ex.getMessage());
}
}
else if (List.class.equals(collectionClass)) {
else if (List.class == collectionClass) {
return (T) new ArrayList();
}
else if (SortedSet.class.equals(collectionClass)) {
else if (SortedSet.class == collectionClass) {
return (T) new TreeSet();
}
else {

View File

@ -118,16 +118,16 @@ public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMe
throws IOException, HttpMessageNotReadableException {
InputStream body = inputMessage.getBody();
if (DOMSource.class.equals(clazz)) {
if (DOMSource.class == clazz) {
return (T) readDOMSource(body);
}
else if (SAXSource.class.equals(clazz)) {
else if (SAXSource.class == clazz) {
return (T) readSAXSource(body);
}
else if (StAXSource.class.equals(clazz)) {
else if (StAXSource.class == clazz) {
return (T) readStAXSource(body);
}
else if (StreamSource.class.equals(clazz) || Source.class.equals(clazz)) {
else if (StreamSource.class == clazz || Source.class == clazz) {
return (T) readStreamSource(body);
}
else {

View File

@ -251,7 +251,7 @@ public class WebDataBinder extends DataBinder {
* @return the empty value (for most fields: null)
*/
protected Object getEmptyValue(String field, Class<?> fieldType) {
if (fieldType != null && boolean.class.equals(fieldType) || Boolean.class.equals(fieldType)) {
if (fieldType != null && boolean.class == fieldType || Boolean.class == fieldType) {
// Special handling of boolean property.
return Boolean.FALSE;
}

View File

@ -740,7 +740,7 @@ public class HandlerMethodInvoker {
private Object checkValue(String name, Object value, Class<?> paramType) {
if (value == null) {
if (boolean.class.equals(paramType)) {
if (boolean.class == paramType) {
return Boolean.FALSE;
}
else if (paramType.isPrimitive()) {

View File

@ -80,7 +80,7 @@ import org.springframework.web.util.UriTemplateHandler;
* HTTP PATCH, HTTP PUT with response body, etc.). Note however that the underlying HTTP
* library used must also support the desired combination.
*
* <p>For each HTTP method there are 3 variants -- two accept a URI template string
* <p>For each HTTP method there are three variants: two accept a URI template string
* and URI variables (array or map) while a third accepts a {@link URI}.
* Note that for URI templates it is assumed encoding is necessary, e.g.
* {@code restTemplate.getForObject("http://example.com/hotel list")} becomes
@ -816,7 +816,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
private final HttpMessageConverterExtractor<T> delegate;
public ResponseEntityResponseExtractor(Type responseType) {
if (responseType != null && !Void.class.equals(responseType)) {
if (responseType != null && Void.class != responseType) {
this.delegate = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
}
else {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -53,8 +53,8 @@ import org.springframework.web.util.WebUtils;
* type {@link MultipartFile} in conjunction with Spring's {@link MultipartResolver}
* abstraction, and arguments of type {@code javax.servlet.http.Part} in conjunction
* with Servlet 3.0 multipart requests. This resolver can also be created in default
* resolution mode in which simple types (int, long, etc.) not annotated
* with @{@link RequestParam} are also treated as request parameters with the
* resolution mode in which simple types (int, long, etc.) not annotated with
* @{@link RequestParam} are also treated as request parameters with the
* parameter name derived from the argument name.
*
* <p>If the method parameter type is {@link Map}, the name specified in the
@ -138,7 +138,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
if (parameter.hasParameterAnnotation(RequestPart.class)) {
return false;
}
else if (MultipartFile.class.equals(paramType) || "javax.servlet.http.Part".equals(paramType.getName())) {
else if (MultipartFile.class == paramType || "javax.servlet.http.Part".equals(paramType.getName())) {
return true;
}
else if (this.useDefaultResolution) {
@ -163,7 +163,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
WebUtils.getNativeRequest(servletRequest, MultipartHttpServletRequest.class);
Object arg;
if (MultipartFile.class.equals(parameter.getParameterType())) {
if (MultipartFile.class == parameter.getParameterType()) {
assertIsMultipartRequest(servletRequest);
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
arg = multipartRequest.getFile(name);
@ -202,7 +202,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
if (arg == null) {
String[] paramValues = webRequest.getParameterValues(name);
if (paramValues != null) {
arg = paramValues.length == 1 ? paramValues[0] : paramValues;
arg = (paramValues.length == 1 ? paramValues[0] : paramValues);
}
}
}
@ -219,27 +219,27 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
private boolean isMultipartFileCollection(MethodParameter parameter) {
Class<?> collectionType = getCollectionParameterType(parameter);
return ((collectionType != null) && collectionType.equals(MultipartFile.class));
return (collectionType != null && MultipartFile.class == collectionType);
}
private boolean isPartCollection(MethodParameter parameter) {
Class<?> collectionType = getCollectionParameterType(parameter);
return ((collectionType != null) && "javax.servlet.http.Part".equals(collectionType.getName()));
return (collectionType != null && "javax.servlet.http.Part".equals(collectionType.getName()));
}
private boolean isPartArray(MethodParameter parameter) {
Class<?> paramType = parameter.getParameterType().getComponentType();
return ((paramType != null) && "javax.servlet.http.Part".equals(paramType.getName()));
return (paramType != null && "javax.servlet.http.Part".equals(paramType.getName()));
}
private boolean isMultipartFileArray(MethodParameter parameter) {
Class<?> paramType = parameter.getParameterType().getComponentType();
return ((paramType != null) && MultipartFile.class.equals(paramType));
return (paramType != null && MultipartFile.class == paramType);
}
private Class<?> getCollectionParameterType(MethodParameter parameter) {
Class<?> paramType = parameter.getParameterType();
if (Collection.class.equals(paramType) || List.class.isAssignableFrom(paramType)){
if (Collection.class == paramType || List.class.isAssignableFrom(paramType)){
Class<?> valueType = GenericCollectionTypeResolver.getCollectionParameterType(parameter);
if (valueType != null) {
return valueType;
@ -258,7 +258,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {
Class<?> paramType = parameter.getParameterType();
if (Map.class.isAssignableFrom(paramType) || MultipartFile.class.equals(paramType) ||
if (Map.class.isAssignableFrom(paramType) || MultipartFile.class == paramType ||
"javax.servlet.http.Part".equals(paramType.getName())) {
return;
}

View File

@ -34,7 +34,7 @@ public class SessionStatusMethodArgumentResolver implements HandlerMethodArgumen
@Override
public boolean supportsParameter(MethodParameter parameter) {
return SessionStatus.class.equals(parameter.getParameterType());
return SessionStatus.class == parameter.getParameterType();
}
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -517,8 +517,9 @@ public abstract class FrameworkPortlet extends GenericPortletBean
// Expose current RequestAttributes to current thread.
RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
PortletRequestAttributes requestAttributes = null;
if (previousRequestAttributes == null || previousRequestAttributes.getClass().equals(PortletRequestAttributes.class) ||
previousRequestAttributes.getClass().equals(ServletRequestAttributes.class)) {
if (previousRequestAttributes == null ||
PortletRequestAttributes.class == previousRequestAttributes.getClass() ||
ServletRequestAttributes.class == previousRequestAttributes.getClass()) {
requestAttributes = new PortletRequestAttributes(request, response);
RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);
}

View File

@ -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.
@ -190,7 +190,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
return depth;
}
// If we've gone as far as we can go and haven't found it...
if (exceptionClass.equals(Throwable.class)) {
if (exceptionClass == Throwable.class) {
return -1;
}
return getDepth(exceptionMapping, exceptionClass.getSuperclass(), depth + 1);

View File

@ -520,7 +520,7 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
}
private String determineDefaultPhase(Method handlerMethod) {
if (!void.class.equals(handlerMethod.getReturnType())) {
if (void.class != handlerMethod.getReturnType()) {
return PortletRequest.RENDER_PHASE;
}
for (Class<?> argType : handlerMethod.getParameterTypes()) {
@ -650,7 +650,7 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
else if (Principal.class.isAssignableFrom(parameterType)) {
return request.getUserPrincipal();
}
else if (Locale.class.equals(parameterType)) {
else if (Locale.class == parameterType) {
return request.getLocale();
}
else if (InputStream.class.isAssignableFrom(parameterType)) {
@ -677,7 +677,7 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
}
return ((MimeResponse) response).getWriter();
}
else if (Event.class.equals(parameterType)) {
else if (Event.class == parameterType) {
if (!(request instanceof EventRequest)) {
throw new IllegalStateException("Event can only get obtained from EventRequest");
}

View File

@ -328,7 +328,7 @@ public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExc
else if (Principal.class.isAssignableFrom(parameterType)) {
return request.getUserPrincipal();
}
else if (Locale.class.equals(parameterType)) {
else if (Locale.class == parameterType) {
return request.getLocale();
}
else if (InputStream.class.isAssignableFrom(parameterType)) {
@ -355,7 +355,7 @@ public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExc
}
return ((MimeResponse) response).getWriter();
}
else if (Event.class.equals(parameterType)) {
else if (Event.class == parameterType) {
if (!(request instanceof EventRequest)) {
throw new IllegalStateException("Event can only get obtained from EventRequest");
}

View File

@ -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.
@ -267,7 +267,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
return depth;
}
// If we've gone as far as we can go and haven't found it...
if (exceptionClass.equals(Throwable.class)) {
if (exceptionClass == Throwable.class) {
return -1;
}
return getDepth(exceptionMapping, exceptionClass.getSuperclass(), depth + 1);

View File

@ -891,7 +891,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
else if (Principal.class.isAssignableFrom(parameterType)) {
return request.getUserPrincipal();
}
else if (Locale.class.equals(parameterType)) {
else if (Locale.class == parameterType) {
return RequestContextUtils.getLocale(request);
}
else if (InputStream.class.isAssignableFrom(parameterType)) {

View File

@ -341,7 +341,7 @@ public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExc
else if (Principal.class.isAssignableFrom(parameterType)) {
return request.getUserPrincipal();
}
else if (Locale.class.equals(parameterType)) {
else if (Locale.class == parameterType) {
return RequestContextUtils.getLocale(request);
}
else if (InputStream.class.isAssignableFrom(parameterType)) {

View File

@ -102,8 +102,8 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
@Override
public boolean supportsParameter(MethodParameter parameter) {
return (HttpEntity.class.equals(parameter.getParameterType()) ||
RequestEntity.class.equals(parameter.getParameterType()));
return (HttpEntity.class == parameter.getParameterType() ||
RequestEntity.class == parameter.getParameterType());
}
@Override
@ -121,7 +121,7 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
Type paramType = getHttpEntityType(parameter);
Object body = readWithMessageConverters(webRequest, parameter, paramType);
if (RequestEntity.class.equals(parameter.getParameterType())) {
if (RequestEntity.class == parameter.getParameterType()) {
URI url = inputMessage.getURI();
HttpMethod httpMethod = inputMessage.getMethod();
return new RequestEntity<Object>(body, inputMessage.getHeaders(), httpMethod, url);

View File

@ -701,7 +701,7 @@ public class MvcUriComponentsBuilder {
this.controllerMethod = method;
this.argumentValues = args;
Class<?> returnType = method.getReturnType();
return (void.class.equals(returnType) ? null : returnType.cast(initProxy(returnType, this)));
return (void.class == returnType ? null : returnType.cast(initProxy(returnType, this)));
}
}

View File

@ -111,7 +111,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageConverterM
if (parameter.hasParameterAnnotation(RequestParam.class)){
return false;
}
else if (MultipartFile.class.equals(parameter.getParameterType())) {
else if (MultipartFile.class == parameter.getParameterType()) {
return true;
}
else if ("javax.servlet.http.Part".equals(parameter.getParameterType().getName())) {
@ -144,7 +144,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageConverterM
String partName = getPartName(parameter);
Object arg;
if (MultipartFile.class.equals(paramType)) {
if (MultipartFile.class == paramType) {
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
arg = multipartRequest.getFile(partName);
}
@ -224,12 +224,12 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageConverterM
private boolean isMultipartFileCollection(MethodParameter methodParam) {
Class<?> collectionType = getCollectionParameterType(methodParam);
return MultipartFile.class.equals(collectionType);
return MultipartFile.class == collectionType;
}
private boolean isMultipartFileArray(MethodParameter methodParam) {
Class<?> paramType = methodParam.getNestedParameterType().getComponentType();
return MultipartFile.class.equals(paramType);
return MultipartFile.class == paramType;
}
private boolean isPartCollection(MethodParameter methodParam) {
@ -244,7 +244,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageConverterM
private Class<?> getCollectionParameterType(MethodParameter methodParam) {
Class<?> paramType = methodParam.getNestedParameterType();
if (Collection.class.equals(paramType) || List.class.isAssignableFrom(paramType)){
if (Collection.class == paramType || List.class.isAssignableFrom(paramType)){
Class<?> valueType = GenericCollectionTypeResolver.getCollectionParameterType(methodParam);
if (valueType != null) {
return valueType;

View File

@ -72,10 +72,10 @@ class RequestResponseBodyAdviceChain implements RequestBodyAdvice, ResponseBodyA
}
private List<Object> getAdvice(Class<?> adviceType) {
if (RequestBodyAdvice.class.equals(adviceType)) {
if (RequestBodyAdvice.class == adviceType) {
return this.requestBodyAdvice;
}
else if (ResponseBodyAdvice.class.equals(adviceType)) {
else if (ResponseBodyAdvice.class == adviceType) {
return this.responseBodyAdvice;
}
else {

View File

@ -69,12 +69,12 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
MultipartRequest.class.isAssignableFrom(paramType) ||
HttpSession.class.isAssignableFrom(paramType) ||
Principal.class.isAssignableFrom(paramType) ||
Locale.class.equals(paramType) ||
TimeZone.class.equals(paramType) ||
Locale.class == paramType ||
TimeZone.class == paramType ||
"java.time.ZoneId".equals(paramType.getName()) ||
InputStream.class.isAssignableFrom(paramType) ||
Reader.class.isAssignableFrom(paramType) ||
HttpMethod.class.equals(paramType));
HttpMethod.class == paramType);
}
@Override
@ -98,16 +98,16 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
else if (HttpSession.class.isAssignableFrom(paramType)) {
return request.getSession();
}
else if (HttpMethod.class.equals(paramType)) {
else if (HttpMethod.class == paramType) {
return ((ServletWebRequest) webRequest).getHttpMethod();
}
else if (Principal.class.isAssignableFrom(paramType)) {
return request.getUserPrincipal();
}
else if (Locale.class.equals(paramType)) {
else if (Locale.class == paramType) {
return RequestContextUtils.getLocale(request);
}
else if (TimeZone.class.equals(paramType)) {
else if (TimeZone.class == paramType) {
TimeZone timeZone = RequestContextUtils.getTimeZone(request);
return (timeZone != null ? timeZone : TimeZone.getDefault());
}

Some files were not shown because too many files have changed in this diff Show More