// Path: src/main/java/pl/domzal/junit/docker/rule/ex/InvalidPortDefinition.java
// public class InvalidPortDefinition extends IllegalStateException {
// 
//     public InvalidPortDefinition(String port) {
//         super("Invalid port: "+port);
//     }
// 
// }


import org.apache.commons.lang3.StringUtils;
import pl.domzal.junit.docker.rule.ex.InvalidPortDefinition;
package pl.domzal.junit.docker.rule;



class Ports {

    public static final String TCP_PORT_SUFFIX = "/tcp";
    public static final String UDP_PORT_SUFFIX = "/udp";
    public static final int PORT_SUFFIX_LENGTH = 4;

    /**
     * Prepare port definition ready for binding.<p/>
     * Example (input -&gt; ouput):
     * <pre>
     * "80" -> "80/tcp"
     * "80/tcp" -> "80/tcp"
     * "80/udp" -> "80/udp"
     * </pre>
     */
    public static String portWithProtocol(String port) {
        if (isPortWithProtocol(port)) {
            return port;
        } else if (StringUtils.isNumeric(port)) {
            return port + "/tcp";
        } else {
// Path: src/main/java/pl/domzal/junit/docker/rule/ex/InvalidPortDefinition.java
// public class InvalidPortDefinition extends IllegalStateException {
// 
//     public InvalidPortDefinition(String port) {
//         super("Invalid port: "+port);
//     }
// 
// }


// Path: src/main/java/pl/domzal/junit/docker/rule/Ports.java
import org.apache.commons.lang3.StringUtils;
import pl.domzal.junit.docker.rule.ex.InvalidPortDefinition;

package pl.domzal.junit.docker.rule;



class Ports {

    public static final String TCP_PORT_SUFFIX = "/tcp";
    public static final String UDP_PORT_SUFFIX = "/udp";
    public static final int PORT_SUFFIX_LENGTH = 4;

    /**
     * Prepare port definition ready for binding.<p/>
     * Example (input -&gt; ouput):
     * <pre>
     * "80" -> "80/tcp"
     * "80/tcp" -> "80/tcp"
     * "80/udp" -> "80/udp"
     * </pre>
     */
    public static String portWithProtocol(String port) {
        if (isPortWithProtocol(port)) {
            return port;
        } else if (StringUtils.isNumeric(port)) {
            return port + "/tcp";
        } else {
            throw new InvalidPortDefinition(port);