package com.redislabs.cytoscape.redisgraph.internal.graph.commands; import java.util.ArrayList; import java.util.List; /** * Command executes all sub commands, if a subcommand fails the exception is thrown. */ public class ComposedCommand extends Command { private final List commands = new ArrayList<>(); private ComposedCommand(List commandList) { commands.addAll(commandList); } @Override public void execute() throws CommandException { for (Command command : commands) { command.execute(); } } public void add(Command command) { commands.add(command); } public static Command create(List commandList) { return new ComposedCommand(commandList); } }