code: public static String getLastSegment(final List<PathSegment> segments) {
          if (segments.isEmpty()) {
              return "";
          }
          return segments.get(segments.size() - 1).getPath();
      }
docs: Get the last path segment.
  @param segments the path segments
  @return the path