I'd really like to be able to define a constructor on sealed interfaces:
sealed interface Path permits WindowsPath, UnixPath {
public Path(String p) {
if (isWindows()) {
return new WindowsPath(p);
}
return new UnixPath(p);
}
}
That way user code to construct an object is always the same: var p = new Path(s);
Instead of: var p = Paths.get(s);