Change type of ExecutorURI value to URI
This commit is contained in:
@@ -1,23 +1,13 @@
|
||||
package ch.unisg.common.valueobject;
|
||||
|
||||
import ch.unisg.common.exception.InvalidExecutorURIException;
|
||||
import java.net.URI;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class ExecutorURI {
|
||||
private String value;
|
||||
private URI value;
|
||||
|
||||
public ExecutorURI(String uri) throws InvalidExecutorURIException {
|
||||
String ip = uri.split(":")[0];
|
||||
int port = Integer.parseInt(uri.split(":")[1]);
|
||||
// Check if valid ip4
|
||||
if (!ip.equalsIgnoreCase("localhost") &&
|
||||
!uri.matches("^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}$")) {
|
||||
throw new InvalidExecutorURIException();
|
||||
// Check if valid port
|
||||
} else if (port < 1024 || port > 65535) {
|
||||
throw new InvalidExecutorURIException();
|
||||
}
|
||||
this.value = uri;
|
||||
public ExecutorURI(String uri) {
|
||||
this.value = URI.create(uri);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user