Class Directory

java.lang.Object
dev.prozilla.pine.common.system.Directory
All Implemented Interfaces:
Cloneable<Directory>, Destructible, Printable

public class Directory extends Object implements Destructible, Cloneable<Directory>, Printable
Represents a directory from the file system.

Can be used to watch a directory for file changes.

  • Constructor Details

    • Directory

      public Directory(String path)
  • Method Details

    • createFileDeserializer

      public <Data> FileDeserializer<Data> createFileDeserializer(String relativePath, Class<Data> dataType, boolean hot)
      Creates a deserializer for a given file.
      Type Parameters:
      Data - The type to deserialize the file to
      Parameters:
      relativePath - The path of the file relative to this directory
      dataType - The data type to deserialize the file to
      hot - true enables hot reloading
      Returns:
      The new file deserializer.
    • createFileDeserializer

      public <Data> FileDeserializer<Data> createFileDeserializer(String relativePath, Class<Data> dataType)
      Creates a file deserializer.
      Type Parameters:
      Data - The type to deserialize the file to
      Parameters:
      relativePath - The path of the file relative to this directory
      dataType - The data type to deserialize the file to
      Returns:
      The new file deserializer.
    • createHotFileDeserializer

      @Contract("_, _ -> new") public <Data> HotFileDeserializer<Data> createHotFileDeserializer(String relativePath, Class<Data> dataType)
      Creates a file deserializer with hot reloading.
      Type Parameters:
      Data - The type to deserialize the file to
      Parameters:
      relativePath - The path of the file relative to this directory
      dataType - The data type to deserialize the file to
      Returns:
      The new file deserializer with hot reloading.
    • getWatcher

      @Contract("-> !null") public DirectoryWatcher getWatcher()
      Creates a new watcher for this directory or returns the existing one if there already is one.
      Returns:
      The directory watcher.
    • getPath

      public String getPath()
    • resolvePath

      public String resolvePath(String relativePath)
      Resolves a path relative to this directory.
      Parameters:
      relativePath - The path relative to this directory.
      Returns:
      The resolved path.
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(Directory directory)
      Description copied from interface: Cloneable
      Checks if the given object is equal to this object.
      Specified by:
      equals in interface Cloneable<Directory>
      Parameters:
      directory - Other object
      Returns:
      true if both objects are equal.
    • clone

      public Directory clone()
      Description copied from interface: Cloneable
      Returns a new object that is equal to this object.
      Specified by:
      clone in interface Cloneable<Directory>
      Overrides:
      clone in class Object
      Returns:
      Clone of this object
    • toString

      @NotNull public @NotNull String toString()
      Description copied from interface: Printable
      Returns a string representation of this object.
      Specified by:
      toString in interface Printable
      Overrides:
      toString in class Object
      Returns:
      String representation of this object.
    • destroy

      public void destroy()
      Destroys the watcher of this directory.
      Specified by:
      destroy in interface Destructible