@@ -48,6 +48,16 @@ public ExposedPort(int port, InternetProtocol protocol) {
4848 this .protocol = protocol ;
4949 }
5050
51+ /**
52+ * Creates an {@link ExposedPort} for the given
53+ * {@link #getPort() port number} and {@link InternetProtocol#DEFAULT}.
54+ *
55+ * @param port the {@link #getPort() port number}
56+ */
57+ public ExposedPort (int port ) {
58+ this (port , InternetProtocol .DEFAULT );
59+ }
60+
5161 /**
5262 * Creates an {@link ExposedPort} for the given parameters.
5363 *
@@ -61,7 +71,8 @@ public ExposedPort(String scheme, int port) {
6171 this (port , InternetProtocol .valueOf (scheme ));
6272 }
6373
64- /** @return the {@link InternetProtocol} */
74+ /** @return the {@link InternetProtocol} of the {@link #getPort() port}
75+ * that the container exposes */
6576 public InternetProtocol getProtocol () {
6677 return protocol ;
6778 }
@@ -75,7 +86,7 @@ public String getScheme() {
7586 return protocol .toString ();
7687 }
7788
78- /** @return the port number */
89+ /** @return the port number that the container exposes */
7990 public int getPort () {
8091 return port ;
8192 }
@@ -107,7 +118,14 @@ public static ExposedPort udp(int port) {
107118 public static ExposedPort parse (String serialized ) throws IllegalArgumentException {
108119 try {
109120 String [] parts = serialized .split ("/" );
110- return new ExposedPort (Integer .valueOf (parts [0 ]), InternetProtocol .parse (parts [1 ]));
121+ switch (parts .length ) {
122+ case 1 :
123+ return new ExposedPort (Integer .valueOf (parts [0 ]));
124+ case 2 :
125+ return new ExposedPort (Integer .valueOf (parts [0 ]), InternetProtocol .parse (parts [1 ]));
126+ default :
127+ throw new IllegalArgumentException ();
128+ }
111129 } catch (Exception e ) {
112130 throw new IllegalArgumentException ("Error parsing ExposedPort '" + serialized + "'" );
113131 }
0 commit comments