Package com.guigarage.vagrant.configuration.builder

Source Code of com.guigarage.vagrant.configuration.builder.VagrantPortForwardingBuilder

package com.guigarage.vagrant.configuration.builder;

import com.guigarage.vagrant.configuration.VagrantPortForwarding;
import com.guigarage.vagrant.configuration.builder.util.VagrantBuilderException;

public class VagrantPortForwardingBuilder {

  private int guestport;

  private int hostport;

  private String name;
 
  public VagrantPortForwardingBuilder() {
  }
 
  public static VagrantPortForwardingBuilder create() {
    return new VagrantPortForwardingBuilder();
  }
 
  public VagrantPortForwardingBuilder withHostPort(int hostport) {
    this.hostport = hostport;
    return this;
  }

  public VagrantPortForwardingBuilder withGuestPort(int guestport) {
    this.guestport = guestport;
    return this;
  }
 
  public VagrantPortForwardingBuilder withName(String name) {
    this.name = name;
    return this;
  }
 
  public VagrantPortForwarding build() {
    if(guestport < 0) {
      throw new VagrantBuilderException("no guestport defined");
    }
    if(hostport < 0) {
      throw new VagrantBuilderException("no hostport defined");
    }
    return new VagrantPortForwarding(name, guestport, hostport);
  }
}
TOP

Related Classes of com.guigarage.vagrant.configuration.builder.VagrantPortForwardingBuilder

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.