Class DirectoryEntry

java.lang.Object
com.google.common.jimfs.DirectoryEntry

final class DirectoryEntry extends Object
Entry 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.

  • Field Details

    • directory

      private final Directory directory
    • name

      private final Name name
    • file

      private final @Nullable File file
    • next

      @Nullable DirectoryEntry next
  • Constructor Details

    • DirectoryEntry

      DirectoryEntry(Directory directory, Name name, @Nullable File file)
  • Method Details

    • exists

      public boolean exists()
      Returns true if and only if this entry represents an existing file.
    • requireExists

      @CanIgnoreReturnValue public DirectoryEntry requireExists(Path pathForException) throws NoSuchFileException
      Checks that this entry exists, throwing an exception if not.
      Returns:
      this
      Throws:
      NoSuchFileException - if this entry does not exist
    • requireDoesNotExist

      @CanIgnoreReturnValue public DirectoryEntry requireDoesNotExist(Path pathForException) throws FileAlreadyExistsException
      Checks that this entry does not exist, throwing an exception if it does.
      Returns:
      this
      Throws:
      FileAlreadyExistsException - if this entry does not exist
    • requireDirectory

      @CanIgnoreReturnValue public DirectoryEntry requireDirectory(Path pathForException) throws NoSuchFileException, NotDirectoryException
      Checks that this entry exists and links to a directory, throwing an exception if not.
      Returns:
      this
      Throws:
      NoSuchFileException - if this entry does not exist
      NotDirectoryException - if this entry does not link to a directory
    • requireSymbolicLink

      @CanIgnoreReturnValue public DirectoryEntry requireSymbolicLink(Path pathForException) throws NoSuchFileException, NotLinkException
      Checks that this entry exists and links to a symbolic link, throwing an exception if not.
      Returns:
      this
      Throws:
      NoSuchFileException - if this entry does not exist
      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:
      IllegalStateException - if the file does not exist
    • fileOrNull

      public @Nullable File fileOrNull()
      Returns the file this entry links to or null if the file does not exist
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object