这个方法有点没看懂

public static void beanExtToBas(Object ext, Object bas) throws Exception
{
Class< ? > extType = ext.getClass();
Class< ? > basType = bas.getClass();
// 获取CCardActiveDestroyInfo中所有的方法
for (Method mBas : basType.getMethods())
{
if (!mBas.getName().substring(0, 3).equals("set"))
{
continue;
}
// 截取所有set方法
String name = mBas.getName().substring(3);
Method mExt = getMethod(extType, "get" + name);
if (mExt == null)
{
name = name + "List";
mExt = getMethod(extType, "get" + name);
if (mExt == null)
{
continue;
}
Object obj = mExt.invoke(ext);
if (obj == null)
{
continue;
}
mBas.invoke(bas, JSON.toJSONString(obj, false));
}
else if (mBas.getParameterTypes()[0] == mExt.getReturnType())
{
Object obj = mExt.invoke(ext);
if (obj == null)
{
continue;
}
mBas.invoke(bas, mExt.invoke(ext));
}
else if (mBas.getParameterTypes()[0] == String.class)
{
Object obj = mExt.invoke(ext);
if (obj == null)
{
continue;
}
mBas.invoke(bas, JSON.toJSONString(obj, false));
}
}
}

  

猜你喜欢

转载自www.cnblogs.com/dondming/p/9077806.html