001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package org.anarres.qemu.exec;
006
007import java.util.List;
008import javax.annotation.Nonnull;
009import org.anarres.qemu.exec.host.chardev.CharDevice;
010
011/**
012 *
013 * @author shevek
014 */
015public class QEmuChardevOption extends AbstractQEmuOption {
016
017    public String id;
018    public CharDevice device;
019
020    public QEmuChardevOption(@Nonnull CharDevice device) {
021        this.device = device;
022    }
023
024    @Nonnull
025    public QEmuChardevOption withId(@Nonnull String id) {
026        this.id = id;
027        return this;
028    }
029
030    @Nonnull
031    public QEmuChardevOption withDevice(@Nonnull CharDevice device) {
032        this.device = device;
033        return this;
034    }
035
036    @Override
037    public void appendTo(List<? super String> line) {
038        StringBuilder buf = new StringBuilder(device.getName());
039        appendTo(buf, "id", id);
040        appendTo(buf, device.getProperties());
041        add(line, "-chardev", buf);
042    }
043}