001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj.command;
006
007/**
008 * This command will only finish if whatever {@link CommandGroup} it is in has no active children.
009 * If it is not a part of a {@link CommandGroup}, then it will finish immediately. If it is itself
010 * an active child, then the {@link CommandGroup} will never end.
011 *
012 * <p>This class is useful for the situation where you want to allow anything running in parallel to
013 * finish, before continuing in the main {@link CommandGroup} sequence.
014 */
015public class WaitForChildren extends Command {
016  @Override
017  protected boolean isFinished() {
018    return getGroup() == null || getGroup().m_children.isEmpty();
019  }
020}