code: public static List<PathSegment> decodePath(String path, boolean decode) {
          List<PathSegment> segments = new LinkedList<>();
  
          if (path == null) {
              return segments;
          }
  
          int s;
          int e = -1;
          do {
              s = e + 1;
              e = path.indexOf('/', s);
  
              if (e > s) {
                  decodePathSegment(segments, path.substring(s, e), decode);
              } else if (e == s) {
                  segments.add(PathSegmentImpl.EMPTY_PATH_SEGMENT);
              }
          } while (e != -1);
          if (s < path.length()) {
              decodePathSegment(segments, path.substring(s), decode);
          } else {
              segments.add(PathSegmentImpl.EMPTY_PATH_SEGMENT);
          }
          return segments;
      }
docs: Decode the path component of a URI as path segments.
  <p>
  Any '/' character in the path is considered to be a deliminator
  between two path segments. Thus if the path is '/' then the path segment
  list will contain two empty path segments. If the path is "//" then
  the path segment list will contain three empty path segments. If the path
  is "/a/" the path segment list will consist of the following path
  segments in order: "", "a" and "".
  </p>
  
  @param path   the path component in encoded form.
  @param decode true if the path segments of the path component
  should be in decoded form.
  @return the list of path segments.