mirror of https://gitee.com/makejava/EasyCode.git
优化过时方法
This commit is contained in:
parent
19a7ddac8f
commit
f3c904a0ee
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue