Record Class FileInfo
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.template.FileInfo
- Record Components:
path- the relative of path of the file on the current file system.name- the name of the file.directory- if this information represents a directory.- if the file or directory is hidden.creationTime- a unix timestamp which represents the creation time of the file.lastModified- a unix timestamp which represents the last time the file was changed.lastAccess- a unix timestamp which represents the last time the file was accessed.size- the size of the file, in bytes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final longThe field for thecreationTimerecord component.private final booleanThe field for thedirectoryrecord component.private final booleanThe field for thehiddenrecord component.private final longThe field for thelastAccessrecord component.private final longThe field for thelastModifiedrecord component.The field for thenamerecord component.The field for thepathrecord component.private final longThe field for thesizerecord component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thecreationTimerecord component.booleanReturns the value of thedirectoryrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanhidden()Returns the value of thehiddenrecord component.longReturns the value of thelastAccessrecord component.longReturns the value of thelastModifiedrecord component.name()Returns the value of thenamerecord component.Constructs a new file information for the given path.Constructs a new file information for the given path.Creates a new file information for the given path and the given file attributes.of(@NonNull Path path, @NonNull BasicFileAttributes attributes) Constructs a new file information for the given path and the given file attributes.path()Returns the value of thepathrecord component.longsize()Returns the value of thesizerecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
path
-
name
-
directory
private final boolean directoryThe field for thedirectoryrecord component. -
creationTime
private final long creationTimeThe field for thecreationTimerecord component. -
lastModified
private final long lastModifiedThe field for thelastModifiedrecord component. -
lastAccess
private final long lastAccessThe field for thelastAccessrecord component. -
size
private final long sizeThe field for thesizerecord component.
-
-
Constructor Details
-
FileInfo
public FileInfo(@NonNull @NonNull String path, @NonNull @NonNull String name, boolean directory, boolean hidden, long creationTime, long lastModified, long lastAccess, long size) Creates an instance of aFileInforecord class.- Parameters:
path- the value for thepathrecord componentname- the value for thenamerecord componentdirectory- the value for thedirectoryrecord componenthidden- the value for thehiddenrecord componentcreationTime- the value for thecreationTimerecord componentlastModified- the value for thelastModifiedrecord componentlastAccess- the value for thelastAccessrecord componentsize- the value for thesizerecord component
-
-
Method Details
-
of
Constructs a new file information for the given path.- Parameters:
path- the path to the file to construct the info for.- Returns:
- the created file information based on the given path.
- Throws:
IOException- if an i/o error occurs while accessing the file attributes of the given path.NullPointerException- if the given path is null.
-
of
@NonNull public static @NonNull FileInfo of(@NonNull @NonNull Path path, @NonNull @NonNull BasicFileAttributes attributes) throws IOException Constructs a new file information for the given path and the given file attributes.- Parameters:
path- the path to the file to construct the info for.attributes- the attributes of the file to use when constructing the file info.- Returns:
- the created file information based on the given path and file attributes.
- Throws:
IOException- if an i/o error occurs while accessing the file attributes of the given path.NullPointerException- if either the given path or file attribute information is null.
-
of
@NonNull public static @NonNull FileInfo of(@NonNull @NonNull Path path, @Nullable @Nullable Path relativePath) throws IOException Constructs a new file information for the given path. The file path in the resulting information will be relative if the relative path is given.- Parameters:
path- the full path of the file to create the information for.relativePath- the relative path to the file to create the information for.- Returns:
- the created file information based on the given path and relative path (if present).
- Throws:
IOException- if an i/o error occurs while accessing the file attributes of the given path.NullPointerException- if the given file path is null.
-
of
@NonNull public static @NonNull FileInfo of(@NonNull @NonNull Path fullPath, @Nullable @Nullable Path relativePath, @NonNull @NonNull BasicFileAttributes attributes) throws IOException Creates a new file information for the given path and the given file attributes. If the given relative path is present it will be used as the path in the created file information.- Parameters:
fullPath- the full path to the file to create the information for.relativePath- the relative path to the file to create the information for.attributes- the attributes of the file to use when constructing the file info.- Returns:
- the created file information based on the given file path, file attributes and the relative path.
- Throws:
IOException- if an i/o error occurs while accessing the file attributes of the given path.NullPointerException- if either the given file path or file attribute information is null.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
path
-
name
-
directory
-
creationTime
public long creationTime()Returns the value of thecreationTimerecord component.- Returns:
- the value of the
creationTimerecord component
-
lastModified
public long lastModified()Returns the value of thelastModifiedrecord component.- Returns:
- the value of the
lastModifiedrecord component
-
lastAccess
public long lastAccess()Returns the value of thelastAccessrecord component.- Returns:
- the value of the
lastAccessrecord component
-
size
-