java - 为什么返回值对象在 URLClassPath 的 getResources 函数中有两个额外的字段?
问题描述
我正在阅读spring boot的源代码。我在阅读时发现了一个问题SpringFactoriesLoader.loadFactoryNames
。返回的URLClassPath.getResources
实现Enumeration<Resource>
,但值有额外的两个字段name
和check
。那么,什么时候将这两个字段添加到返回值中呢?
public Enumeration<Resource> getResources(final String var1, final boolean var2) {
return new Enumeration<Resource>() {
private int index = 0;
private int[] cache = URLClassPath.this.getLookupCache(var1);
private Resource res = null;
private boolean next() {
if (this.res != null) {
return true;
} else {
do {
URLClassPath.Loader var1x;
if ((var1x = URLClassPath.this.getNextLoader(this.cache, this.index++)) == null) {
return false;
}
this.res = var1x.getResource(var1, var2);
} while(this.res == null);
return true;
}
}
public boolean hasMoreElements() {
return this.next();
}
public Resource nextElement() {
if (!this.next()) {
throw new NoSuchElementException();
} else {
Resource var1x = this.res;
this.res = null;
return var1x;
}
}
};
}
我正在使用 Intellij 调试程序,结果是
解决方案
在这种情况下,结果实例是一个匿名类,它捕获getResources
参数的值(final String var1, final boolean var2)
。
推荐阅读
- python - 如何在 matplotlib 中更改 xticks 的旋转?
- hibernate - 带有@JoinTable 的单向@OneToMany 不更新连接表
- python - matplotlib 图例中的上标格式
- javascript - 在我手动刷新页面之前,加载功能窗口不会触发?
- javascript - 为什么这会同时显示数组和对象的行为
- php - PHP / Laravel - Tesseract OCR - 文件的完整路径
- c++ - C ++ 11尝试使用正则表达式提取子字符串
- c# - WEB API & BL 关系
- vb.net - 在 dll (vb.net) 中调用方法时传递参数与公共变量
- android - 使用 @Path 和 @Query 参数改造创建端点