Class Path<T>

  • All Implemented Interfaces:
    java.lang.Iterable<Segment<T>>
    Direct Known Subclasses:
    AbsolutePath

    public abstract class Path<T>
    extends java.lang.Object
    implements java.lang.Iterable<Segment<T>>
    An iterable of Segments. Paths can either be absolute (starting with '/'), or rootless (not starting with '/').

    Immutable and thread safe.

    See Also:
    RFC 3986 - Path
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract boolean isAbsolute()
      Indicates whether this path is absolute (begins with '/') or not.
      static <ENCODES> AbsolutePath<ENCODES> path()
      Factory method for creating an empty AbsolutePath.
      static <ENCODES> AbsolutePath<ENCODES> path​(java.lang.Iterable<Segment<ENCODES>> segments)
      Factory method for creating AbsolutePaths from an Iterable of Segments.
      static AbsolutePath<java.lang.String> path​(java.lang.String firstSegment, java.lang.String... segments)
      Factory method for creating AbsolutePaths from Strings.
      static <ENCODES> AbsolutePath<ENCODES> path​(Segment<ENCODES>... segments)
      Factory method for creating AbsolutePaths from Segments.
      static <ENCODES> Path<ENCODES> rootlessPath()
      Factory method for creating empty rootless Paths.
      static <ENCODES> Path<ENCODES> rootlessPath​(java.lang.Iterable<Segment<ENCODES>> segments)
      Factory method for creating rootless Paths from an Iterable of Segments.
      static Path<java.lang.String> rootlessPath​(java.lang.String firstSegment, java.lang.String... segments)
      Factory method for creating rootless Paths from Strings.
      static <ENCODES> Path<ENCODES> rootlessPath​(Segment<ENCODES>... segments)
      Factory method for creating rootless Paths from Segments.
      abstract java.util.List<Segment<T>> segments()
      Returns the list of Segments that this path represents.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • Method Detail

      • rootlessPath

        public static Path<java.lang.String> rootlessPath​(java.lang.String firstSegment,
                                                          java.lang.String... segments)
        Factory method for creating rootless Paths from Strings.
        Parameters:
        firstSegment - a String representing the first segment.
        segments - any further segments.
        Returns:
        a Path representing the given Strings.
      • rootlessPath

        public static <ENCODES> Path<ENCODES> rootlessPath()
        Factory method for creating empty rootless Paths.
        Type Parameters:
        ENCODES - The type of value represented by the path segments - String in the general case.
        Returns:
        an empty Path.
      • rootlessPath

        @SafeVarargs
        public static <ENCODES> Path<ENCODES> rootlessPath​(Segment<ENCODES>... segments)
        Factory method for creating rootless Paths from Segments.
        Type Parameters:
        ENCODES - The type of value represented by the path segments - String in the general case.
        Parameters:
        segments - Segments that will be represented by this Path.
        Returns:
        a Path representing the given Segments.
      • rootlessPath

        public static <ENCODES> Path<ENCODES> rootlessPath​(java.lang.Iterable<Segment<ENCODES>> segments)
        Factory method for creating rootless Paths from an Iterable of Segments.
        Type Parameters:
        ENCODES - The type of value represented by the path segments - String in the general case.
        Parameters:
        segments - Iterable of Segments that will be represented by this Path.
        Returns:
        a Path representing the given Segments.
      • path

        public static AbsolutePath<java.lang.String> path​(java.lang.String firstSegment,
                                                          java.lang.String... segments)
        Factory method for creating AbsolutePaths from Strings.
        Parameters:
        firstSegment - a String representing the first segment.
        segments - any further segments.
        Returns:
        a AbsolutePath representing the given Strings.
      • path

        public static <ENCODES> AbsolutePath<ENCODES> path()
        Factory method for creating an empty AbsolutePath.
        Type Parameters:
        ENCODES - The type of value represented by the path segments - String in the general case.
        Returns:
        an empty AbsolutePath.
      • path

        @SafeVarargs
        public static <ENCODES> AbsolutePath<ENCODES> path​(Segment<ENCODES>... segments)
        Factory method for creating AbsolutePaths from Segments.
        Type Parameters:
        ENCODES - The type of value represented by the path segments - String in the general case.
        Parameters:
        segments - Segments that will be represented by this AbsolutePath.
        Returns:
        a AbsolutePath representing the given Segments.
      • path

        public static <ENCODES> AbsolutePath<ENCODES> path​(java.lang.Iterable<Segment<ENCODES>> segments)
        Factory method for creating AbsolutePaths from an Iterable of Segments.
        Type Parameters:
        ENCODES - The type of value represented by the path segments - String in the general case.
        Parameters:
        segments - Iterable of Segments that will be represented by this AbsolutePath.
        Returns:
        a AbsolutePath representing the given Segments.
      • isAbsolute

        public abstract boolean isAbsolute()
        Indicates whether this path is absolute (begins with '/') or not.
        Returns:
        whether this path is absolute (begins with '/') or not.
      • segments

        public abstract java.util.List<Segment<T>> segments()
        Returns the list of Segments that this path represents. Note that this List contains the same elements as returned by calling iterator() on this.
        Returns:
        the list of Segments that this path represents.