com.github.dakusui.actionunit.core.Action Maven / Gradle / Ivy
Show all versions of actionunit Show documentation
package com.github.dakusui.actionunit.core;
import com.github.dakusui.actionunit.actions.*;
import java.util.Formattable;
public interface Action extends Formattable {
void accept(Visitor visitor);
abstract class Builder {
public abstract A build();
/**
* A synonym of {@code build()} method. This method is defined not to use a
* method name 'build', which introduces extra word not relating to what is
* being achieved.
*
* If you prefer a word 'build' in your code, simply use {@code build}
* method.
*
* @return An object built by {@code build} method.
*/
final public A $() {
return build();
}
}
interface Visitor {
@SuppressWarnings("unused")
default void visit(Action action) {
throw new UnsupportedOperationException();
}
default void visit(Leaf action) {
this.visit((Action) action);
}
default void visit(Named action) {
this.visit((Action) action);
}
default void visit(Composite action) {
this.visit((Action) action);
}
default void visit(ForEach action) {
this.visit((Action) action);
}
default void visit(While action) {
this.visit((Action) action);
}
default void visit(When action) {
this.visit((Action) action);
}
default void visit(With action) {
this.visit((Action) action);
}
default void visit(Attempt action) {
this.visit((Action) action);
}
default void visit(Retry action) {
this.visit((Action) action);
}
default void visit(TimeOut action) {
this.visit((Action) action);
}
}
}