class UriComponent {

    public static List<PathSegment> parsePathSegments(String path, boolean decode) {
        List<PathSegment> result = new ArrayList<>();
        if (!(path == null || path.isEmpty())) {
            // remove leading slash
            if (path.charAt(0) == '/') {
                path = path.substring(1);
            }

            int p = 0;
            int n = 0;
            while (n < path.length()) {
                n = path.indexOf('/', p);
                if (n < 0) {
                    n = path.length();
                }

                result.add(PathSegmentImpl.fromString(path.substring(p, n), decode));
                p = n + 1;
            }
        }
        return result;
    }

    private  UriComponent();

}