public class UniversalPath extends Object implements Serializable
Path that is keeping the user input as-is
and only parses it when used.
Dynamic Config needs to keep all user inputs.
The problems with Path are:
1. Parsing: Paths.get() will parse some user input into some segments. The input and parsing is per-platform so it can lead to different outcomes in both parsing and toString()
- On Win: Paths.get("a/b") and Paths.get("a\\b") give 2 segments
- On Lin: Paths.get("a/b") give 2 segments and Paths.get("a\\b") gives 1 segment
2. User input is lost: when parsed, we loose the path separator that was initially used. As a consequence, all serializations could lead to different results that is different than the user input since it depends on the system where we are calling toString().
So this class aims at resolving all of that, by keeping the user input, that will be used for equality checks, serialization and deserialization, and also provide the equivalent of the Path API when used.
The parsing of the user input will be only done when the object will be queried and converted to a Path
| Modifier and Type | Method and Description |
|---|---|
static UniversalPath |
create(boolean absolute,
List<String> segments) |
static UniversalPath |
create(boolean absolute,
String... segments) |
boolean |
equals(Object o) |
static UniversalPath |
fromLocalPath(Path local) |
int |
hashCode() |
Path |
toLocalPath() |
String |
toString() |
public static UniversalPath fromLocalPath(Path local)
public static UniversalPath create(boolean absolute, List<String> segments)
public static UniversalPath create(boolean absolute, String... segments)
public Path toLocalPath()
Copyright © 2022. All rights reserved.