AnnotationParser.java 文件源码

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

项目:silly-android 作者:
/**
 * Verifies that the given field is a {@link View} or crashes.
 *
 * @param field  The field you are checking
 * @param object The object instance holding the field
 * @throws IllegalArgumentException When field is not a {@link View}
 */
@VisibleForTesting
static void verifyTypeOfView(@NonNull final Field field, @NonNull final Object object) {
    try {
        field.setAccessible(true);
        Object value = field.get(object);
        if (value instanceof View || View.class.isAssignableFrom(field.getType())) {
            return;
        }
    } catch (IllegalAccessException ignored) {}
    throw new IllegalArgumentException("Field \n\t'" + String.valueOf(field) + "\n is not a View, instead it is a " + field.getType().getSimpleName());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号