001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package org.anarres.qemu.exec.host.chardev;
006
007import java.util.Map;
008import javax.annotation.Nonnull;
009
010/**
011 *
012 * @author shevek
013 */
014public abstract class AbstractSocketCharDevice extends AbstractCharDevice {
015
016    public boolean server;
017    public boolean nowait;
018    public boolean telnet;
019
020    public AbstractSocketCharDevice(String name) {
021        super(name);
022    }
023
024    public AbstractSocketCharDevice(String name, boolean server, boolean nowait) {
025        super(name);
026        this.server = server;
027        this.nowait = nowait;
028    }
029
030    @Nonnull
031    public AbstractSocketCharDevice withServer(boolean server) {
032        this.server = server;
033        return this;
034    }
035
036    @Nonnull
037    public AbstractSocketCharDevice withNowait(boolean nowait) {
038        this.nowait = nowait;
039        return this;
040    }
041
042    @Nonnull
043    public AbstractSocketCharDevice withTelnet(boolean telnet) {
044        this.telnet = telnet;
045        return this;
046    }
047
048    @Override
049    protected void addProperties(Map<String, Object> m) {
050        super.addProperties(m);
051        if (server)
052            m.put("server", null);
053        if (nowait)
054            m.put("nowait", null);
055        if (telnet)
056            m.put("telnet", null);
057    }
058}