// 先看看有没对应的构造函数
Mirror<T> mirror = Mirror.me(type);
for (Constructor<?> cc : type.getConstructors()) {
Class<?>[] pts = cc.getParameterTypes();
MatchType mt = Mirror.matchParamTypes(pts, argTypes);
re.setMatchType(mt);
// 正好合适
if (MatchType.YES == mt) {
return re.setBorning(new ConstructorBorning(cc));
}
// 差一个参数,说明这个构造函数有变参数组
else if (MatchType.LACK == mt) {
re.setLackArg(Mirror.blankArrayArg(pts));
return re.setBorning(new ConstructorBorning(cc));
}
// 看看整个输入的参数是不是变参
else if (null != dynaArg && pts.length == 1 && pts[0] == dynaArg.getClass()) {
return re.setBorning(new DynamicConstructorBorning(cc));
}
}
// 看看有没有对应静态工厂函数
Method[] sms = mirror.getStaticMethods();
for (Method m : sms) {
Class<?>[] pts = m.getParameterTypes();
MatchType mt = Mirror.matchParamTypes(pts, argTypes);
re.setMatchType(mt);
if (MatchType.YES == mt) {
return re.setBorning(new MethodBorning<T>(m));
} else if (MatchType.LACK == mt) {
re.setLackArg(Mirror.blankArrayArg(pts));