class Paths {

    static Path parse(String path, boolean resolveJsonPointerEscapes) {
        // Remove leading and trailing whitespace and '/' characters ...
        path = Strings.trim(path, (c) -> c < ' ' || c == '/');
        if (path.length() == 0) {
            return RootPath.INSTANCE;
        }
        String[] segments = PATH_SEPARATOR_PATTERN.split(path);
        if (segments.length == 1) {
            return new SingleSegmentPath(parseSegment(segments[0], resolveJsonPointerEscapes));
        }
        if (resolveJsonPointerEscapes) {
            for (int i = 0; i != segments.length; ++i) {
                segments[i] = parseSegment(segments[i], true);
            }
        }
        return new MultiSegmentPath(segments);
    }

    private  Paths();

}