Use AnnotationUtils.findAnnotation(…) instead of AnnotatedElement.isAnnotationPresent(…).

Enable use of meta annotations by leveraging MergedAnnotations.

Closes #2500
This commit is contained in:
XenoAmess
2021-11-23 04:45:56 +08:00
committed by Mark Paluch
parent 8bd81a796d
commit ca723d11c7
7 changed files with 33 additions and 14 deletions

View File

@@ -34,6 +34,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.GenericTypeResolver;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.core.convert.converter.ConverterRegistry;
@@ -42,6 +43,7 @@ import org.springframework.core.convert.converter.GenericConverter.ConvertiblePa
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.data.convert.ConverterBuilder.ConverterAware;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.repository.RepositoryDefinition;
import org.springframework.data.util.Streamable;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -57,6 +59,7 @@ import org.springframework.util.ObjectUtils;
* @author Thomas Darimont
* @author Christoph Strobl
* @author Mark Paluch
* @author Xeno Amess
* @since 2.0
*/
public class CustomConversions {
@@ -757,8 +760,8 @@ public class CustomConversions {
Assert.notNull(converter, "Converter must not be null!");
Class<?> type = converter.getClass();
boolean isWriting = type.isAnnotationPresent(WritingConverter.class);
boolean isReading = type.isAnnotationPresent(ReadingConverter.class);
boolean isWriting = AnnotationUtils.findAnnotation(type, WritingConverter.class) != null;
boolean isReading = AnnotationUtils.findAnnotation(type, ReadingConverter.class) != null;
if (converter instanceof ConverterAware) {