BeanUtils.java 文件源码

java
阅读 40 收藏 0 点赞 0 评论 0

项目:comparison 作者:
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;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号