分离链接方法调用

时间:2014-07-14 10:31:17

标签: java javafx

是否有可能在他们的电话中分离方法?所以我们不会将这些方法称为行?我的意思是下面的代码片段:

//configure path transition and run it
 PathTransition pathTransition = PathTransitionBuilder.create()
            .duration(Duration.seconds(6))
            .path(path)
            .node(rect)
            .orientation(OrientationType.ORTHOGONAL_TO_TANGENT)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(false)
            .build();
    pathTransition.play();

1 个答案:

答案 0 :(得分:1)

正在发生的是每个方法实际上都返回了方法所在的对象,这允许进行另一个方法调用。

PathTransition pathTransition = PathTransitionBuilder.create()
        .duration(Duration.seconds(6))
        .path(path)
        .node(rect)
        .orientation(OrientationType.ORTHOGONAL_TO_TANGENT)
        .cycleCount(Timeline.INDEFINITE)
        .autoReverse(false)
        .build();

与:

相同
PathTransitionBuilder pathTransitionBuilder = PathTransitionBuilder.create();
pathTransitionBuilder .duration(Duration.seconds(6));
pathTransitionBuilder .path(path);
pathTransitionBuilder .node(rect);
pathTransitionBuilder .orientation(OrientationType.ORTHOGONAL_TO_TANGENT);
pathTransitionBuilder .cycleCount(Timeline.INDEFINITE);
pathTransitionBuilder .autoReverse(false);
PathTransition pathTransition = pathTransitionBuilder.build();