Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onlab.stc; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableSet; |
| 19 | import com.google.common.collect.Sets; |
| 20 | |
| 21 | import java.util.Set; |
| 22 | |
| 23 | /** |
| 24 | * Represenation of a related group of steps. |
| 25 | */ |
| 26 | public class Group extends Step { |
| 27 | |
| 28 | private final Set<Step> children = Sets.newHashSet(); |
| 29 | |
| 30 | /** |
| 31 | * Creates a new test step. |
| 32 | * |
| 33 | * @param name group name |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame] | 34 | * @param command default command |
| 35 | * @param env default path to file to be sourced into the environment |
| 36 | * @param cwd default path to current working directory for the step |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 37 | * @param group optional group to which this step belongs |
Thomas Vachuska | 664f29e | 2015-12-08 12:58:16 -0800 | [diff] [blame] | 38 | * @param delay seconds to delay before executing |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 39 | */ |
Thomas Vachuska | 664f29e | 2015-12-08 12:58:16 -0800 | [diff] [blame] | 40 | public Group(String name, String command, String env, String cwd, Group group, int delay) { |
| 41 | super(name, command, env, cwd, group, delay); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns the set of child steps and groups contained within this group. |
| 46 | * |
| 47 | * @return set of children |
| 48 | */ |
| 49 | public Set<Step> children() { |
| 50 | return ImmutableSet.copyOf(children); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Adds the specified step or group as a child of this group. |
| 55 | * |
| 56 | * @param child child step or group to add |
| 57 | */ |
| 58 | public void addChild(Step child) { |
| 59 | children.add(child); |
| 60 | } |
| 61 | } |