public static String getIdProp(Class c){
for(Method m : c.getMethods()){
boolean isGetter = m.getName().startsWith("get");
boolean noParameters = (m.getParameterTypes().length == 0);
boolean notGetClass = !m.getName().equals("getClass");
if (isGetter && noParameters && notGetClass) {
boolean hasIdMethod = m.isAnnotationPresent(Id.class) || m.isAnnotationPresent(EmbeddedId.class);
String fieldName = acessorToProperty(m.getName());
boolean hasIdField = isIdField(c, fieldName);
if(hasIdMethod || hasIdField){
return fieldName;
}
}
}
return null;
}
BeanUtils.java 文件源码
java
阅读 40
收藏 0
点赞 0
评论 0
项目:comparison
作者:
评论列表
文章目录