Package org.gradle.api.file
Class RelativePath
java.lang.Object
org.gradle.api.file.RelativePath
- All Implemented Interfaces:
Serializable
,Comparable<RelativePath>
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:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRelativePath
(boolean endsWithFile, String... segments) Creates aRelativePath
. -
Method Summary
Modifier and TypeMethodDescriptionAppends the given names to the end of this path.append
(RelativePath other) Appends the given path to the end of this path.int
boolean
Returns the parent of this path.String[]
int
hashCode()
boolean
isFile()
static RelativePath
static RelativePath
parse
(boolean isFile, RelativePath parent, String path) plus
(RelativePath other) Appends the given path to the end of this path.Prepends the given names to the start of this path.replaceLastName
(String name) Returns a copy of this path, with the last name replaced with the given name.toString()
-
Field Details
-
EMPTY_ROOT
-
-
Constructor Details
-
RelativePath
Creates aRelativePath
.- Parameters:
endsWithFile
- - if true, the path ends with a file, otherwise a directory
-
-
Method Details
-
getSegments
-
segmentIterator
-
isFile
public boolean isFile() -
getPathString
-
getFile
-
getLastName
-
equals
-
hashCode
public int hashCode() -
toString
-
getParent
Returns the parent of this path.- Returns:
- The parent of this path, or null if this is the root path.
-
parse
-
parse
-
replaceLastName
Returns a copy of this path, with the last name replaced with the given name.
- Parameters:
name
- The name.- Returns:
- The path.
-
append
Appends the given path to the end of this path.
- Parameters:
other
- The path to append- Returns:
- The new path
-
plus
Appends the given path to the end of this path.
- Parameters:
other
- The path to append- Returns:
- The new path
-
append
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
Prepends the given names to the start of this path.- Parameters:
segments
- The names to prepend- Returns:
- The new path.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<RelativePath>
-