/**
* Returns all fields from the given class, including its superclass fields. If cached fields are available, they will be used; instead, a new list will
* be saved to the cache.
*
* @param classInstance Which class to look into
* @return A list of declared class' fields. Do not modify this instance
*/
@NonNull
@VisibleForTesting
static List<Field> getAllFields(@NonNull final Class<?> classInstance) {
Class<?> parsedClass = classInstance;
final String name = parsedClass.getName();
List<Field> allFields = FIELD_CACHE.get(name);
if (allFields == null || allFields.isEmpty()) {
allFields = new LinkedList<>();
while (parsedClass != null && parsedClass != Object.class) {
allFields.addAll(Arrays.asList(parsedClass.getDeclaredFields()));
parsedClass = parsedClass.getSuperclass();
}
FIELD_CACHE.put(name, allFields);
}
return allFields;
}
AnnotationParser.java 文件源码
java
阅读 39
收藏 0
点赞 0
评论 0
项目:silly-android
作者:
评论列表
文章目录