001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2008-2017. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj.command;
009
010/**
011 * This command will only finish if whatever {@link CommandGroup} it is in has no active children.
012 * If it is not a part of a {@link CommandGroup}, then it will finish immediately. If it is itself
013 * an active child, then the {@link CommandGroup} will never end.
014 *
015 * <p>This class is useful for the situation where you want to allow anything running in parallel
016 * to finish, before continuing in the main {@link CommandGroup} sequence.
017 */
018public class WaitForChildren extends Command {
019
020  protected boolean isFinished() {
021    return getGroup() == null || getGroup().m_children.isEmpty();
022  }
023}