Class UniversalPath
- java.lang.Object
-
- org.terracotta.angela.common.util.UniversalPath
-
- All Implemented Interfaces:
Serializable
public class UniversalPath extends Object implements Serializable
A raw path is aPaththat 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
- Author:
- Mathieu Carbou
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UniversalPathcreate(boolean absolute, String... segments)static UniversalPathcreate(boolean absolute, List<String> segments)booleanequals(Object o)static UniversalPathfromLocalPath(Path local)inthashCode()PathtoLocalPath()StringtoString()
-
-
-
Method Detail
-
fromLocalPath
public static UniversalPath fromLocalPath(Path local)
-
create
public static UniversalPath create(boolean absolute, List<String> segments)
-
create
public static UniversalPath create(boolean absolute, String... segments)
-
toLocalPath
public Path toLocalPath()
-
-