public class TestBeanWrapper {
private final Map extendProperties = new HashMap(); //只初始化一次,不能指向另一个引用
private BeanWrapperImpl beanWrapper;
private PropertyDescriptor[] descriptors;
private boolean hasReflected = false;
public static void main(String[] args) {
TestBeanWrapper tb=new TestBeanWrapper();
tb.test();
}
void test(){
BeanWrapperImpl bi=new BeanWrapperImpl(this);
PropertyDescriptor[] alldescriptors=bi.getPropertyDescriptors();
int length=alldescriptors.length;
List list = new ArrayList();
for (int i = 0; i < alldescriptors.length; i++) {
if (alldescriptors[i].getReadMethod() != null
&& alldescriptors[i].getWriteMethod() != null) {
list.add(alldescriptors[i]);
System.out.println(alldescriptors[i].getDisplayName()); //显示这个类的实例属性
}
}
PropertyDescriptor[] descriptors = (PropertyDescriptor[]) list
.toArray(new PropertyDescriptor[0]);
System.out.println(descriptors.length+" list.length="+list.size());
}
public BeanWrapperImpl getBeanWrapper() {
return beanWrapper;
}
public void setBeanWrapper(BeanWrapperImpl beanWrapper) {
this.beanWrapper = beanWrapper;
}
public PropertyDescriptor[] getDescriptors() {
return descriptors;
}
public void setDescriptors(PropertyDescriptor[] descriptors) {
this.descriptors = descriptors;
}
public boolean isHasReflected() {
return hasReflected;
}
public void setHasReflected(boolean hasReflected) {
this.hasReflected = hasReflected;
}
public Map getExtendProperties() {
return extendProperties;
}
}