优化过时方法

This commit is contained in:
makejava 2022-10-13 10:37:35 +08:00
parent 19a7ddac8f
commit f3c904a0ee
1 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,8 @@ package com.sjhy.plugin.factory;
import com.sjhy.plugin.entity.AbstractItem;
import java.lang.reflect.InvocationTargetException;
/**
* 抽象的项目工厂
*
@ -13,9 +15,9 @@ public class AbstractItemFactory {
public static <T extends AbstractItem<T>> T createDefaultVal(Class<T> cls) {
try {
T instance = cls.newInstance();
T instance = cls.getDeclaredConstructor().newInstance();
return instance.defaultVal();
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException("构建示例失败", e);
}
}