1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-11-22 01:48:50 +00:00

feat: 添加数据类型检测提示

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-12-26 14:52:40 +08:00
parent b307dcbb62
commit cb1cb7f492
2 changed files with 8 additions and 3 deletions

View File

@ -121,6 +121,9 @@ public abstract class AbstractInjectConfig {
if (type.equals(String.class)) { if (type.equals(String.class)) {
value = ChatColor.translateAlternateColorCodes('&', String.valueOf(value)); value = ChatColor.translateAlternateColorCodes('&', String.valueOf(value));
} }
if (value != null && !type.isAssignableFrom(value.getClass())) {
Log.w("字段 %s 默认类型为 %s 但解析后为 %s 可能存在转换错误!", field.getName(), type.getName(), value.getClass().getName());
}
field.set(this, value); field.set(this, value);
Log.d("设置字段 %s 为 %s ", field.getName(), value); Log.d("设置字段 %s 为 %s ", field.getName(), value);
} }

View File

@ -1,8 +1,5 @@
package pw.yumc.YumCore.config.inject; package pw.yumc.YumCore.config.inject;
import org.bukkit.configuration.ConfigurationSection;
import pw.yumc.YumCore.config.exception.ConfigParseException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -11,6 +8,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
import pw.yumc.YumCore.config.exception.ConfigParseException;
/** /**
* 注入配置类解析 * 注入配置类解析
* *
@ -66,6 +67,7 @@ public class InjectParse {
public static class DateFormatParse implements Parse<DateFormat> { public static class DateFormatParse implements Parse<DateFormat> {
public DateFormatParse() { public DateFormatParse() {
allparse.put(DateFormat.class, this); allparse.put(DateFormat.class, this);
allparse.put(SimpleDateFormat.class, this);
} }
@Override @Override