Package dev.prozilla.pine.common.system
Class Directory
java.lang.Object
dev.prozilla.pine.common.system.Directory
- All Implemented Interfaces:
Cloneable<Directory>,Destructible,Printable
Represents a directory from the file system.
Can be used to watch a directory for file changes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a new object that is equal to this object.<Data> FileDeserializer<Data> createFileDeserializer(String relativePath, Class<Data> dataType) Creates a file deserializer.<Data> FileDeserializer<Data> createFileDeserializer(String relativePath, Class<Data> dataType, boolean hot) Creates a deserializer for a given file.<Data> HotFileDeserializer<Data> createHotFileDeserializer(String relativePath, Class<Data> dataType) Creates a file deserializer with hot reloading.voiddestroy()Destroys the watcher of this directory.booleanChecks if the given object is equal to this object.booleangetPath()Creates a new watcher for this directory or returns the existing one if there already is one.resolvePath(String relativePath) Resolves a path relative to this directory.@NotNull StringtoString()Returns a string representation of this object.
-
Constructor Details
-
Directory
-
-
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 directorydataType- The data type to deserialize the file tohot-trueenables 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 directorydataType- 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 directorydataType- The data type to deserialize the file to- Returns:
- The new file deserializer with hot reloading.
-
getWatcher
Creates a new watcher for this directory or returns the existing one if there already is one.- Returns:
- The directory watcher.
-
getPath
-
resolvePath
Resolves a path relative to this directory.- Parameters:
relativePath- The path relative to this directory.- Returns:
- The resolved path.
-
equals
-
equals
Description copied from interface:CloneableChecks if the given object is equal to this object. -
clone
Description copied from interface:CloneableReturns a new object that is equal to this object. -
toString
Description copied from interface:PrintableReturns a string representation of this object. -
destroy
public void destroy()Destroys the watcher of this directory.- Specified by:
destroyin interfaceDestructible
-