我无法理解以下片段。我的意思是到底发生了什么。谁能解释一下发生了什么?
这是片段:
protected NodeService getUnprotectedNodeService()
{
if (this.unprotectedNodeService == null)
{
this.unprotectedNodeService = (NodeService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "nodeService");
}
return this.unprotectedNodeService;
}
最佳答案
如果尚未设置,它会设置 this.unprotectedNodeService
(并且还会返回它..),如果已经设置,它只会返回它。
似乎是一种缓存机制,可以防止多次调用重型方法
关于java - 下面的代码片段中发生了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6263242/