2525 */
2626public abstract class OperationBuilder implements Operation
2727{
28- private class CompositeOperation extends OperationBuilder
28+
29+ /**
30+ * Return a new {@link OperationBuilder} that takes no action when {@link #perform(Rewrite, EvaluationContext)} is
31+ * invoked.
32+ */
33+ public static OperationBuilder create ()
34+ {
35+ return new OperationBuilder () {
36+ @ Override
37+ public void perform (Rewrite event , EvaluationContext context )
38+ {}
39+ };
40+ }
41+
42+ /**
43+ * Wrap a given {@link Operation} as a new {@link OperationBuilder} that performs the action of the original
44+ * {@link Operation} when {@link #perform(Rewrite, EvaluationContext)} is invoked.
45+ */
46+ public static OperationBuilder wrap (Operation operation )
47+ {
48+ return new CompositeOperation (OperationBuilder .create (), operation );
49+ }
50+
51+ /**
52+ * Join this instance with another {@link Operation} to be performed. All joined operations are guaranteed to be
53+ * evaluated. Operations are evaluated in the order in which they are added.
54+ */
55+ public OperationBuilder and (final Operation other )
56+ {
57+ return new CompositeOperation (this , other );
58+ }
59+
60+ private static class CompositeOperation extends OperationBuilder
2961 {
3062 private final Operation left ;
3163 private final Operation right ;
@@ -44,13 +76,4 @@ public void perform(final Rewrite event, final EvaluationContext context)
4476 }
4577
4678 }
47-
48- /**
49- * Join this instance with another {@link Operation} to be performed.
50- */
51- public OperationBuilder and (final Operation other )
52- {
53- return new CompositeOperation (this , other );
54- }
55-
5679}
0 commit comments