src/org/nutz/lang/born/Borns.java
@SuppressWarnings({"rawtypes", "unchecked"})
	private static <T> BornContext<T> evalWithArgTypes(boolean accurate,
													   Class<T> type,
													   Class<?>[] argTypes,
													   Object dynaArg) {
		// 准备好返回对象
		BornContext<T> re = new BornContext<T>();

		// 先看看有没对应的构造函数
		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));
				return re.setBorning(new MethodBorning<T>(m));
			} else if (null != dynaArg && pts.length == 1) {
				if (pts[0] == dynaArg.getClass()) {
					return re.setBorning(new DynaMethodBorning<T>(m));
				}
			}
		}
		// 如果不是要精确查找的话
		if (!accurate) {
			// 找到一个长度合适的构造函数，准备转换
			try {
				for (Constructor<?> cc : type.getConstructors()) {
					Class<?>[] pts = cc.getParameterTypes();
					if (canBeCasted(argTypes, pts)) {
						re.setMatchType(MatchType.NEED_CAST);
						re.setCastType(pts);
						return re.setBorning(new ConstructorCastingBorning(cc));
					}
				}
			}
			catch (RuntimeException e) {}
			// 有没有变参的静态构造方法
			try {
				for (Method m : sms) {
					Class<?>[] pts = m.getParameterTypes();
					if (canBeCasted(argTypes, pts)) {
						re.setMatchType(MatchType.NEED_CAST);
						re.setCastType(pts);
						return re.setBorning(new MethodCastingBorning<T>(m));
					}
				}
			}
			catch (Exception e) {}
		}

		return null;
	}
@SuppressWarnings({"rawtypes", "unchecked"})
	private static <T> BornContext<T> evalWithArgTypes(boolean accurate,
													   Class<T> type,
													   Class<?>[] argTypes,
													   Object dynaArg) {
		// 准备好返回对象
		BornContext<T> re = new BornContext<T>();

		// 先看看有没对应的构造函数
		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));
				return re.setBorning(new MethodBorning<T>(m));
			} else if (null != dynaArg && pts.length == 1) {
				if (pts[0] == dynaArg.getClass()) {
					return re.setBorning(new DynaMethodBorning<T>(m));
				}
			}
		}
		// 如果不是要精确查找的话
		if (!accurate) {
			// 找到一个长度合适的构造函数，准备转换
			try {
				for (Constructor<?> cc : type.getConstructors()) {
					Class<?>[] pts = cc.getParameterTypes();
					if (canBeCasted(argTypes, pts)) {
						re.setMatchType(MatchType.NEED_CAST);
						re.setCastType(pts);
						return re.setBorning(new ConstructorCastingBorning(cc));
					}
				}
			}
			catch (RuntimeException e) {}
			// 有没有变参的静态构造方法
			try {
				for (Method m : sms) {
					Class<?>[] pts = m.getParameterTypes();
					if (canBeCasted(argTypes, pts)) {
						re.setMatchType(MatchType.NEED_CAST);
						re.setCastType(pts);
						return re.setBorning(new MethodCastingBorning<T>(m));
					}
				}
			}
			catch (Exception e) {}
		}

		return null;
	}
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) private static < T > BornContext < T > evalWithArgTypes ( boolean accurate , Class < T > type , Class < ? > [ ] argTypes , Object dynaArg ) { // 准备好返回对象 BornContext < T > re = new BornContext < T > ( ) ; // 先看看有没对应的构造函数 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 ) ) ; return re . setBorning ( new MethodBorning < T > ( m ) ) ; } else if ( null != dynaArg && pts . length == 1 ) { if ( pts [ 0 ] == dynaArg . getClass ( ) ) { return re . setBorning ( new DynaMethodBorning < T > ( m ) ) ; } } } // 如果不是要精确查找的话 if ( ! accurate ) { // 找到一个长度合适的构造函数，准备转换 try { for ( Constructor < ? > cc : type . getConstructors ( ) ) { Class < ? > [ ] pts = cc . getParameterTypes ( ) ; if ( canBeCasted ( argTypes , pts ) ) { re . setMatchType ( MatchType . NEED_CAST ) ; re . setCastType ( pts ) ; return re . setBorning ( new ConstructorCastingBorning ( cc ) ) ; } } } catch ( RuntimeException e ) { } // 有没有变参的静态构造方法 try { for ( Method m : sms ) { Class < ? > [ ] pts = m . getParameterTypes ( ) ; if ( canBeCasted ( argTypes , pts ) ) { re . setMatchType ( MatchType . NEED_CAST ) ; re . setCastType ( pts ) ; return re . setBorning ( new MethodCastingBorning < T > ( m ) ) ; } } } catch ( Exception e ) { } } return null ; }
根据一个调用参数类型数组，获取一个对象的构建信息

@param <T>
对象类型信息
@param accurate
是否需要精确匹配
@param type
对象类型
@param argTypes
参考参数类型数组
@param dynaAry
参考参数类型信息是否是一个变参数组
@return 构建信息对象
根据一个调用参数类型数组，获取一个对象的构建信息