All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dakusui.actionunit.visitors.reporting.ActionTreeBuilder Maven / Gradle / Ivy

There is a newer version: 6.1.5
Show newest version
package com.github.dakusui.actionunit.visitors.reporting;

import com.github.dakusui.actionunit.core.Action;
import com.github.dakusui.actionunit.visitors.ActionScanner;

import java.util.Objects;

public class ActionTreeBuilder extends ActionScanner implements Action.Visitor {
  public static Node traverse(Action action) {
    ActionTreeBuilder actionTreeBuilder = new ActionTreeBuilder();
    Objects.requireNonNull(action).accept(actionTreeBuilder);
    return actionTreeBuilder.getRootNode();
  }

  private ActionTreeBuilder() {
  }

  @SuppressWarnings("unchecked")
  protected   void pushNode(Node node) {
    if (!getCurrentPath().isEmpty())
      getCurrentPath().peek().add((Node) node);
    getCurrentPath().push((Node) node);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy