Package org.gradle.util
Class Path
- java.lang.Object
-
- org.gradle.util.Path
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
absolutePath(java.lang.String path)
Resolves the given name relative to this path.Path
absolutePath(Path path)
Path
append(Path path)
Appends the supplied path to this path, returning the new path.Path
child(java.lang.String name)
Creates a child of this path with the given name.int
compareTo(Path other)
boolean
equals(java.lang.Object o)
java.lang.String
getName()
Returns the base name of this path, or null if this path is the root path.Path
getParent()
Returns the parent of this path, or null if this path has no parent.java.lang.String
getPath()
int
hashCode()
boolean
isAbsolute()
static Path
path(java.lang.String path)
java.lang.String
relativePath(java.lang.String path)
Calculates a path relative to this path.Path
relativePath(Path path)
Path
removeFirstSegments(int n)
java.lang.String
segment(int index)
int
segmentCount()
java.util.List<java.lang.String>
segments()
returns an immutable list of the segments of this pathPath
takeFirstSegments(int n)
Returns aPath
containing only the firstn
segments of thisPath
.java.lang.String
toString()
static void
validatePath(java.lang.String path)
throws if no path is specified
-
-
-
Field Detail
-
ROOT
public static final Path ROOT
-
SEPARATOR
public static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
path
public static Path path(@Nullable java.lang.String path)
-
validatePath
@Incubating public static void validatePath(@Nullable java.lang.String path)
throws if no path is specified- Since:
- 8.5
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
append
public Path append(Path path)
Appends the supplied path to this path, returning the new path. The resulting path with be absolute or relative based on the path being appended _to_. It makes no difference if the _appended_ path is absolute or relative.path(':a:b').append(path(':c:d')) == path(':a:b:c:d') path(':a:b').append(path('c:d')) == path(':a:b:c:d') path('a:b').append(path(':c:d')) == path('a:b:c:d') path('a:b').append(path('c:d')) == path('a:b:c:d')
-
getPath
public java.lang.String getPath()
-
segments
@Incubating public java.util.List<java.lang.String> segments()
returns an immutable list of the segments of this path- Since:
- 8.5
-
equals
public boolean equals(@Nullable java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(Path other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Path>
-
getParent
@Nullable public Path getParent()
Returns the parent of this path, or null if this path has no parent.- Returns:
- The parent of this path.
-
getName
@Nullable public java.lang.String getName()
Returns the base name of this path, or null if this path is the root path.- Returns:
- The base name,
-
child
public Path child(java.lang.String name)
Creates a child of this path with the given name.
-
absolutePath
public java.lang.String absolutePath(java.lang.String path)
Resolves the given name relative to this path. If an absolute path is provided, it is returned.
-
isAbsolute
public boolean isAbsolute()
-
relativePath
public java.lang.String relativePath(java.lang.String path)
Calculates a path relative to this path. If the given path is not a child of this path, it is returned unmodified.
-
segmentCount
public int segmentCount()
-
removeFirstSegments
public Path removeFirstSegments(int n)
-
segment
public java.lang.String segment(int index)
-
takeFirstSegments
@Incubating public Path takeFirstSegments(int n)
Returns aPath
containing only the firstn
segments of thisPath
. The returnedPath
will be absolute if thisPath
is absolute.- Parameters:
n
- number of segments to take from this Path, must be greater than or equal to 1- Since:
- 8.4
-
-