我是靠谱客的博主 开心咖啡,这篇文章主要介绍ReflectionUtils的findField方法,现在分享给大家,希望可以做个参考。

public static Field findField(Class<?> clazz, String name, Class<?> type) {
    Assert.notNull(clazz, "Class must not be null");
    Assert.isTrue(name != null || type != null, "Either name or type of the field must be specified");

    for(Class searchType = clazz; !Object.class.equals(searchType) && searchType != null; searchType = searchType.getSuperclass()) {
        Field[] fields = searchType.getDeclaredFields();
        Field[] var5 = fields;
        int var6 = fields.length;

        for(int var7 = 0; var7 < var6; ++var7) {
            Field field = var5[var7];
            if((name == null || name.equals(field.getName())) && (type == null || type.equals(field.getType()))) {
                return field;
            }
        }
    }

    return null;
}

最后

以上就是开心咖啡最近收集整理的关于ReflectionUtils的findField方法的全部内容,更多相关ReflectionUtils内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部