import com.hkfs.fundamental.api.data.PojoDataObjectBase;
import com.hkfs.fundamental.api.params.WebPageSessionParameter;
/**
* Created by Mr.vivion on 2017/6/17.类包
*/
public class CloudUserInfoView extends PojoDataObjectBase {
private String accid;
private String token;
private String name;
private String icon;
public String getAccid() {
return accid;
}
public void setAccid(String accid) {
this.accid = accid;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
}
@Test
public void aaa() {
CloudUserInfoView cloudUserInfoView =new CloudUserInfoView();
try {
BeanInfo beanInfo = Introspector.getBeanInfo(cloudUserInfoView.getClass(), PojoDataObjectBase.class);
PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
if (pds != null) {
for (PropertyDescriptor pd : pds) {
Method writeMethod = pd.getWriteMethod();
if (writeMethod == null) {
continue;
}
Method readMethod = pd.getReadMethod();
if (readMethod == null) {
continue;
}
String parameterName = processParameterName(readMethod.getName());
System.out.println(parameterName);
if (parameterName.contains("id")) {
//包含该字段权限
cloudUserInfoView.putExtendedParameterValue(parameterName,"100");
continue;
}
//不包含设置为空
writeMethod.invoke(cloudUserInfoView, (Object) null);
}
}
} catch (IntrospectionException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
System.out.println("a");
}
//去除set和get参数
private String processParameterName(String getMethodName) {
return makeFirstLetterLowerCase(getMethodName.substring(3));
}
/**
* 第一个字母小写
* @param str 字符串
* @return 第一个字母小写其他字母不变的字符串
*/
public String makeFirstLetterLowerCase(String str) {
if (str != null && str.length() > 0) {
if (!StrUtils.isLowerCase(str.charAt(0))) {
return (str.charAt(0) + "").toLowerCase() + str.substring(1);
}
}
return str;
}
菜单
本页目录