📄 abstractvalueobject.java
字号:
package com.cownew.PIS.framework.common;
import java.beans.PropertyDescriptor;
import java.util.Collection;
import java.util.Map;
import com.cownew.ctk.common.ExceptionUtils;
import com.cownew.ctk.common.PropertyUtils;
abstract public class AbstractValueObject implements IValueObject
{
public String toString()
{
try
{
StringBuffer sb = new StringBuffer();
PropertyDescriptor[] propDescs = org.apache.commons.beanutils.PropertyUtils
.getPropertyDescriptors(this);
for (int i = 0, n = propDescs.length; i < n; i++)
{
String name = propDescs[i].getName();
if (!org.apache.commons.beanutils.PropertyUtils.isReadable(
this, name))
{
continue;
}
Object propValue = PropertyUtils.getProperty(this, name);
// 为防止对象自引用或者循环引用,造成死循环,因此对于关联属性不进行级联描述
if (propValue instanceof Collection || propValue instanceof Map)
{
sb.append(name).append("=[more...]");
} else if (propValue instanceof IValueObject)
{
String className = propValue.getClass().getName();
sb.append(name).append("=[").append(className).append("]");
} else
{
sb.append(name).append("=[").append(propValue).append("]");
}
}
return sb.toString();
} catch (Exception e)
{
throw ExceptionUtils.toRuntimeException(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -