Class RelativePath
java.lang.Object
org.gradle.api.file.RelativePath
- All Implemented Interfaces:
Serializable, CharSequence, Comparable<RelativePath>
public class RelativePath
extends Object
implements Serializable, Comparable<RelativePath>, 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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRelativePath(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.charcharAt(int index) intboolean@Nullable RelativePathReturns the parent of this path.String[]inthashCode()booleanisFile()intlength()static RelativePathstatic RelativePathparse(boolean isFile, @Nullable 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.subSequence(int start, int end) toString()Methods inherited from interface CharSequence
chars, codePoints, getChars, isEmpty
-
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
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
getFile
-
getLastName
-
equals
-
hashCode
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
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:
endsWithFile- when true, the new path refers to a file.segments- The names to append.- 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:
compareToin interfaceComparable<RelativePath>
-