All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 commands;

    public CommandChain(Class type, List commands) {
        this.type = type;
        this.commands = commands;
    }

    public Class getType() {
        return type;
    }

    public List 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 commands) {
        return new CommandChain(type, commands);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy