build().perform()和perform()有什么区别 [英] What is the difference between build().perform() and perform()

查看:103
本文介绍了build().perform()和perform()有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些文章建议 现在build()包含在perform()本身中,而其他人则建议 当链接多个动作时使用build().perform() 在一起.

Some articles suggest that now build() is included in perform() itself, while others suggest that build().perform() is used when multiple actions are to be chained together.

推荐答案

build()包含在perform()中,您可以在

build() is included in perform(), you can see it in the source code

public void perform() {
    build().perform();
}

方法内部的perform()调用内部类BuiltAction中的perform()方法.

The perform() inside the methods calls the perform() method in the inner class BuiltAction.

在代码中调用build().perform()实际上是两次调用build(),即build().build().perform().

Calling build().perform() in your code is actually calling build() twice, build().build().perform().

构建

生成一个复合动作,其中包含到目前为止的所有动作,准备进行 被执行(并重置内部构建器状态,因此随后 对build()的调用将包含新序列).

Generates a composite action containing all actions so far, ready to be performed (and resets the internal builder state, so subsequent calls to build() will contain fresh sequences).

执行

一种无需调用即可执行动作的便捷方法 首先build().

A convenience method for performing the actions without calling build() first.

这几乎不会引起误解(IMO),因为即使隐式调用了build().

This is little misleading (IMO), because build() is being called, even if implicitly.

这篇关于build().perform()和perform()有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆