is there an interface for "something that can be converted to a path"?
so my API can take "path-like" things without forcing the user to convert at the use site.
maybe there's a generic bound for this?
s
Sam
03/07/2024, 10:20 AM
Maybe you just want a
() -> Path
?
k
Klitos Kyriacou
03/07/2024, 12:02 PM
Do you mean an object that is either a
File
or a
String
or a
URI
or an actual
Path
? There's no interface that defines them, but you could use function overloading. However, it's more type-safe (and self-documenting) to force the user to convert to
Path
at the call site, and many stdlib (or Java API) methods already do this.