Efficient type plus annotation comparisons during converter retrieval

Issue: SPR-14926
Issue: SPR-12926
(cherry picked from commit f6b8b84)
This commit is contained in:
Juergen Hoeller
2016-11-30 22:22:44 +01:00
parent 7ac9f92bc2
commit cbc512f3be
3 changed files with 80 additions and 52 deletions

View File

@@ -231,6 +231,7 @@ public class FormattingConversionService extends GenericConversionService
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
this.annotationType = annotationType;
this.annotationFormatterFactory = annotationFormatterFactory;
this.fieldType = fieldType;
@@ -284,6 +285,7 @@ public class FormattingConversionService extends GenericConversionService
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
this.annotationType = annotationType;
this.annotationFormatterFactory = annotationFormatterFactory;
this.fieldType = fieldType;
@@ -350,16 +352,13 @@ public class FormattingConversionService extends GenericConversionService
if (this == other) {
return true;
}
if (!(other instanceof AnnotationConverterKey)) {
return false;
}
AnnotationConverterKey otherKey = (AnnotationConverterKey) other;
return (this.annotation.equals(otherKey.annotation) && this.fieldType.equals(otherKey.fieldType));
return (this.fieldType == otherKey.fieldType && this.annotation.equals(otherKey.annotation));
}
@Override
public int hashCode() {
return (this.annotation.hashCode() + 29 * this.fieldType.hashCode());
return (this.fieldType.hashCode() * 29 + this.annotation.hashCode());
}
}