java.lang.Object
io.github.astrapi69.file.create.FileInfo
- Direct Known Subclasses:
FileContentInfo
The class
FileInfo
represents file information, including name, path, and directory flag.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
FileInfo.FileInfoBuilder<C extends FileInfo,
B extends FileInfo.FileInfoBuilder<C, B>> The builder class for constructing `FileInfo` objects. -
Constructor Summary
ConstructorsModifierConstructorDescriptionFileInfo()
Constructs a new empty `FileInfo`.protected
FileInfo
(FileInfo.FileInfoBuilder<?, ?> b) Constructs a new `FileInfo` from the builder.Constructs a new `FileInfo` from the givenFile
object.Constructs a new `FileInfo` with the given name, path, and directory flag. -
Method Summary
Modifier and TypeMethodDescriptionstatic FileInfo.FileInfoBuilder<?,
?> builder()
Returns a builder for constructing `FileInfo` objects.protected boolean
Internal method for checking equality with another object.boolean
Indicates whether some other object is "equal to" this one.getName()
Retrieves the name of the file.getPath()
Retrieves the path of the file.int
hashCode()
Returns a hash code value for the object.boolean
Checks if the file is a directory.void
setDirectory
(boolean directory) Sets whether the file is a directory.void
Sets the name of the file.void
Sets the path of the file.Returns a builder initialized with the values of this `FileInfo` object.toFile()
Converts this `FileInfo` object to aFile
object.static File
Converts the given `FileInfo` object to aFile
objectstatic FileInfo
toFileInfo
(File file) Converts the givenFile
object to a `FileInfo` object.toString()
Returns a string representation of the object.
-
Constructor Details
-
FileInfo
Constructs a new `FileInfo` with the given name, path, and directory flag.- Parameters:
name
- the name of the filepath
- the path of the filedirectory
- true if the file is a directory, false otherwise
-
FileInfo
public FileInfo()Constructs a new empty `FileInfo`. -
FileInfo
Constructs a new `FileInfo` from the givenFile
object.- Parameters:
file
- the file from which to construct the `FileInfo`- Throws:
NullPointerException
- if the file is null
-
FileInfo
Constructs a new `FileInfo` from the builder.- Parameters:
b
- the builder used to construct the `FileInfo`
-
-
Method Details
-
toFile
Converts this `FileInfo` object to aFile
object.- Returns:
- the new `File` object from this `FileInfo`
-
toFileInfo
Converts the givenFile
object to a `FileInfo` object.- Parameters:
file
- the file to convert to `FileInfo`- Returns:
- a new `FileInfo` object from the given file
- Throws:
NullPointerException
- if the file is null
-
toFile
Converts the given `FileInfo` object to aFile
object- Parameters:
fileInfo
- the `FileInfo` object to convert to `File`- Returns:
- the new `File` object the given `FileInfo` object
-
builder
Returns a builder for constructing `FileInfo` objects.- Returns:
- a new instance of `FileInfoBuilder`
-
getName
Retrieves the name of the file.- Returns:
- the name of the file
-
setName
Sets the name of the file.- Parameters:
name
- the new name to set
-
getPath
Retrieves the path of the file.- Returns:
- the path of the file
-
setPath
Sets the path of the file.- Parameters:
path
- the new path to set
-
isDirectory
public boolean isDirectory()Checks if the file is a directory.- Returns:
- true if the file is a directory, false otherwise
-
setDirectory
public void setDirectory(boolean directory) Sets whether the file is a directory.- Parameters:
directory
- true if the file is a directory, false otherwise
-
equals
Indicates whether some other object is "equal to" this one. -
canEqual
Internal method for checking equality with another object.- Parameters:
other
- the object to compare with- Returns:
- true if the objects can be considered equal, false otherwise
-
hashCode
public int hashCode()Returns a hash code value for the object. -
toString
Returns a string representation of the object. -
toBuilder
Returns a builder initialized with the values of this `FileInfo` object.- Returns:
- a new `FileInfoBuilder` initialized with this `FileInfo` values
-