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

org.zeroturnaround.process.CompositeProcess Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version
package org.zeroturnaround.process;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Contains other {@link SystemProcess}es preserving their order.
 */
public abstract class CompositeProcess extends AbstractProcess {

  protected final List children;

  public CompositeProcess(List children) {
    this.children = children;
  }

  @Override
  public String getDescription() {
    List result = new ArrayList();
    for (SystemProcess child : children) {
      result.add(child.toString());
    }
    return result.toString();
  }

  @Override
  public String toString() {
    List result = new ArrayList();
    for (SystemProcess child : children) {
      result.add(child.toString());
    }
    return getClass().getSimpleName() + result.toString();
  }

  protected static void invokeDestroy(SystemProcess killer, boolean forceful) throws IOException, InterruptedException {
    if (forceful) {
      killer.destroyForcefully();
    }
    else {
      killer.destroyGracefully();
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy