RelativePath (Gradle API 7.6.4)

Package org.gradle.api.file

## Class RelativePath

- java.lang.Object
- - org.gradle.api.file.RelativePath

- All Implemented Interfaces:
    `java.io.Serializable`, `java.lang.CharSequence`, `java.lang.Comparable<RelativePath>`

      public class RelativePath
      extends java.lang.Object
      implements java.io.Serializable, java.lang.Comparable<RelativePath>, java.lang.CharSequence

  Represents a relative path from some base directory to a file. Used in file copying to represent both a source and target file path when copying files.

  `RelativePath` instances are immutable.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static RelativePath` | `EMPTY_ROOT` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RelativePath​(boolean endsWithFile, java.lang.String... segments)` | Creates a `RelativePath`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `RelativePath` | `append​(boolean endsWithFile, java.lang.String... segments)` | Appends the given names to the end of this path.
    `RelativePath` | `append​(RelativePath other)` | Appends the given path to the end of this path.
    `char` | `charAt​(int index)` |
    `int` | `compareTo​(RelativePath o)` |
    `boolean` | `equals​(java.lang.Object o)` |
    `java.io.File` | `getFile​(java.io.File baseDir)` |
    `java.lang.String` | `getLastName()` |
    `RelativePath` | `getParent()` | Returns the parent of this path.
    `java.lang.String` | `getPathString()` |
    `java.lang.String[]` | `getSegments()` |
    `int` | `hashCode()` |
    `boolean` | `isFile()` |
    `int` | `length()` |
    `static RelativePath` | `parse​(boolean isFile, java.lang.String path)` |
    `static RelativePath` | `parse​(boolean isFile, RelativePath parent, java.lang.String path)` |
    `RelativePath` | `plus​(RelativePath other)` | Appends the given path to the end of this path.
    `RelativePath` | `prepend​(java.lang.String... segments)` | Prepends the given names to the start of this path.
    `RelativePath` | `replaceLastName​(java.lang.String name)` | Returns a copy of this path, with the last name replaced with the given name.
    `java.util.ListIterator<java.lang.String>` | `segmentIterator()` |
    `java.lang.CharSequence` | `subSequence​(int start, int end)` |
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.lang.CharSequence

      `chars, codePoints`

- - ### Field Detail

    - #### EMPTY_ROOT

          public static final RelativePath EMPTY_ROOT

  - ### Constructor Detail

    - #### RelativePath

          public RelativePath​(boolean endsWithFile,
                              java.lang.String... segments)

      Creates a `RelativePath`.
      Parameters:
        `endsWithFile` - - if true, the path ends with a file, otherwise a directory

  - ### Method Detail

    - #### getSegments

          public java.lang.String[] getSegments()

    - #### segmentIterator

          public java.util.ListIterator<java.lang.String> segmentIterator()

    - #### isFile

          public boolean isFile()

    - #### getPathString

          public java.lang.String getPathString()

    - #### length

          public int length()

      Specified by:
        `length` in interface `java.lang.CharSequence`

    - #### charAt

          public char charAt​(int index)

      Specified by:
        `charAt` in interface `java.lang.CharSequence`

    - #### subSequence

          public java.lang.CharSequence subSequence​(int start,
                                                    int end)

      Specified by:
        `subSequence` in interface `java.lang.CharSequence`

    - #### getFile

          public java.io.File getFile​(java.io.File baseDir)

    - #### getLastName

          public java.lang.String getLastName()

    - #### equals

          public boolean equals​(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Specified by:
        `toString` in interface `java.lang.CharSequence`
      Overrides:
        `toString` in class `java.lang.Object`

    - #### getParent

          public RelativePath getParent()

      Returns the parent of this path.
      Returns:
        The parent of this path, or null if this is the root path.

    - #### parse

          public static RelativePath parse​(boolean isFile,
                                           java.lang.String path)

    - #### parse

          public static RelativePath parse​(boolean isFile,
                                           @Nullable
                                           RelativePath parent,
                                           java.lang.String path)

    - #### replaceLastName

          public RelativePath replaceLastName​(java.lang.String name)

      Returns a copy of this path, with the last name replaced with the given name.

      Parameters:
        `name` - The name.
      Returns:
        The path.

    - #### append

          public RelativePath append​(RelativePath other)

      Appends the given path to the end of this path.

      Parameters:
        `other` - The path to append
      Returns:
        The new path

    - #### plus

          public RelativePath plus​(RelativePath other)

      Appends the given path to the end of this path.

      Parameters:
        `other` - The path to append
      Returns:
        The new path

    - #### append

          public RelativePath append​(boolean endsWithFile,
                                     java.lang.String... segments)

      Appends the given names to the end of this path.
      Parameters:
        `segments` - The names to append.
        `endsWithFile` - when true, the new path refers to a file.
      Returns:
        The new path.

    - #### prepend

          public RelativePath prepend​(java.lang.String... segments)

      Prepends the given names to the start of this path.
      Parameters:
        `segments` - The names to prepend
      Returns:
        The new path.

    - #### compareTo

          public int compareTo​(RelativePath o)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<RelativePath>`