Efficient type plus annotation comparisons during converter retrieval
Issue: SPR-14926 Issue: SPR-12926
This commit is contained in:
@@ -52,11 +52,9 @@ public class FormattingConversionService extends GenericConversionService
|
||||
|
||||
private StringValueResolver embeddedValueResolver;
|
||||
|
||||
private final Map<AnnotationConverterKey, GenericConverter> cachedPrinters =
|
||||
new ConcurrentHashMap<>(64);
|
||||
private final Map<AnnotationConverterKey, GenericConverter> cachedPrinters = new ConcurrentHashMap<>(64);
|
||||
|
||||
private final Map<AnnotationConverterKey, GenericConverter> cachedParsers =
|
||||
new ConcurrentHashMap<>(64);
|
||||
private final Map<AnnotationConverterKey, GenericConverter> cachedParsers = new ConcurrentHashMap<>(64);
|
||||
|
||||
|
||||
@Override
|
||||
@@ -231,6 +229,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 +283,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 +350,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user