From 5ecfb51f3f36aadac65906885189a1d95c050a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91?= Date: Sat, 28 Sep 2024 19:33:09 +0800 Subject: [PATCH] =?UTF-8?q?[6.2.0][dev]=20=E4=BF=AE=E5=A4=8D=20ObjectConve?= =?UTF-8?q?rter=20=E8=BD=AC=E6=8D=A2=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nightconfig/core/conversion/ObjectConverter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/basic/basic-configuration/src/main/java/com/electronwill/nightconfig/core/conversion/ObjectConverter.java b/module/basic/basic-configuration/src/main/java/com/electronwill/nightconfig/core/conversion/ObjectConverter.java index ea564c324..3f5ee94b9 100644 --- a/module/basic/basic-configuration/src/main/java/com/electronwill/nightconfig/core/conversion/ObjectConverter.java +++ b/module/basic/basic-configuration/src/main/java/com/electronwill/nightconfig/core/conversion/ObjectConverter.java @@ -531,6 +531,9 @@ private T createInstance(Class tClass) { * 获取字段的转换器 */ private Converter getConverter(Field field) { + // 优先获取 @Converter 注解 + Converter converter = AnnotationUtils.getConverter(field); + if (converter != null) return converter; // 已知的包装类型 if (field.getType() == UUID.class) { return new UUIDConverter(); @@ -538,8 +541,6 @@ private Converter getConverter(Field field) { if (Map.class.isAssignableFrom(field.getType())) { return new MapConverter(); } - Converter converter = AnnotationUtils.getConverter(field); - if (converter != null) return converter; return null; }