Package com.google.common.jimfs
Class DirectoryEntry
- java.lang.Object
-
- com.google.common.jimfs.DirectoryEntry
-
final class DirectoryEntry extends java.lang.ObjectEntry in a directory, containing references to the directory itself, the file the entry links to and the name of the entry.May also represent a non-existent entry if the name does not link to any file in the directory.
-
-
Constructor Summary
Constructors Constructor Description DirectoryEntry(Directory directory, Name name, @Nullable File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Directorydirectory()Returns the directory containing this entry.booleanequals(java.lang.Object obj)booleanexists()Returnstrueif and only if this entry represents an existing file.Filefile()Returns the file this entry links to.@Nullable FilefileOrNull()Returns the file this entry links to ornullif the file does not existinthashCode()Namename()Returns the name of this entry.DirectoryEntryrequireDirectory(java.nio.file.Path pathForException)Checks that this entry exists and links to a directory, throwing an exception if not.DirectoryEntryrequireDoesNotExist(java.nio.file.Path pathForException)Checks that this entry does not exist, throwing an exception if it does.DirectoryEntryrequireExists(java.nio.file.Path pathForException)Checks that this entry exists, throwing an exception if not.DirectoryEntryrequireSymbolicLink(java.nio.file.Path pathForException)Checks that this entry exists and links to a symbolic link, throwing an exception if not.java.lang.StringtoString()
-
-
-
Field Detail
-
directory
private final Directory directory
-
name
private final Name name
-
file
private final @Nullable File file
-
next
@Nullable DirectoryEntry next
-
-
Method Detail
-
exists
public boolean exists()
Returnstrueif and only if this entry represents an existing file.
-
requireExists
@CanIgnoreReturnValue public DirectoryEntry requireExists(java.nio.file.Path pathForException) throws java.nio.file.NoSuchFileException
Checks that this entry exists, throwing an exception if not.- Returns:
- this
- Throws:
java.nio.file.NoSuchFileException- if this entry does not exist
-
requireDoesNotExist
@CanIgnoreReturnValue public DirectoryEntry requireDoesNotExist(java.nio.file.Path pathForException) throws java.nio.file.FileAlreadyExistsException
Checks that this entry does not exist, throwing an exception if it does.- Returns:
- this
- Throws:
java.nio.file.FileAlreadyExistsException- if this entry does not exist
-
requireDirectory
@CanIgnoreReturnValue public DirectoryEntry requireDirectory(java.nio.file.Path pathForException) throws java.nio.file.NoSuchFileException, java.nio.file.NotDirectoryException
Checks that this entry exists and links to a directory, throwing an exception if not.- Returns:
- this
- Throws:
java.nio.file.NoSuchFileException- if this entry does not existjava.nio.file.NotDirectoryException- if this entry does not link to a directory
-
requireSymbolicLink
@CanIgnoreReturnValue public DirectoryEntry requireSymbolicLink(java.nio.file.Path pathForException) throws java.nio.file.NoSuchFileException, java.nio.file.NotLinkException
Checks that this entry exists and links to a symbolic link, throwing an exception if not.- Returns:
- this
- Throws:
java.nio.file.NoSuchFileException- if this entry does not existjava.nio.file.NotLinkException- if this entry does not link to a symbolic link
-
directory
public Directory directory()
Returns the directory containing this entry.
-
name
public Name name()
Returns the name of this entry.
-
file
public File file()
Returns the file this entry links to.- Throws:
java.lang.IllegalStateException- if the file does not exist
-
fileOrNull
public @Nullable File fileOrNull()
Returns the file this entry links to ornullif the file does not exist
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-