io.remotecontrol.CommandChain Maven / Gradle / Ivy
package io.remotecontrol;
import io.remotecontrol.util.UnexpectedIOException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
public class CommandChain implements Serializable {
private static final long serialVersionUID = 1L;
private final Class type;
private final List extends T> commands;
public CommandChain(Class type, List extends T> commands) {
this.type = type;
this.commands = commands;
}
public Class getType() {
return type;
}
public List extends T> getCommands() {
return commands;
}
public void writeTo(OutputStream outputStream) {
try {
SerializationUtil.serialize(this, outputStream);
} catch (IOException e) {
throw new UnexpectedIOException("command chain should be serializable", e);
}
}
public static CommandChain of(Class type, T... commands) {
return new CommandChain(type, Arrays.asList(commands));
}
public static CommandChain of(Class type, List extends T> commands) {
return new CommandChain(type, commands);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy