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.
hidden - 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.

public record FileInfo(@NonNull String path, @NonNull String name, boolean directory, boolean hidden, long creationTime, long lastModified, long lastAccess, long size) extends Record
Represents a file which is stored on any file system which is accessible.
Since:
4.0
  • Field Details

    • path

      @NonNull private final @NonNull String path
      The field for the path record component.
    • name

      @NonNull private final @NonNull String name
      The field for the name record component.
    • directory

      private final boolean directory
      The field for the directory record component.
    • hidden

      private final boolean hidden
      The field for the hidden record component.
    • creationTime

      private final long creationTime
      The field for the creationTime record component.
    • lastModified

      private final long lastModified
      The field for the lastModified record component.
    • lastAccess

      private final long lastAccess
      The field for the lastAccess record component.
    • size

      private final long size
      The field for the size record 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 a FileInfo record class.
      Parameters:
      path - the value for the path record component
      name - the value for the name record component
      directory - the value for the directory record component
      hidden - the value for the hidden record component
      creationTime - the value for the creationTime record component
      lastModified - the value for the lastModified record component
      lastAccess - the value for the lastAccess record component
      size - the value for the size record component
  • Method Details

    • of

      @NonNull public static @NonNull FileInfo of(@NonNull @NonNull Path path) throws IOException
      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

      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

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • path

      @NonNull public @NonNull String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • name

      @NonNull public @NonNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • directory

      public boolean directory()
      Returns the value of the directory record component.
      Returns:
      the value of the directory record component
    • hidden

      public boolean hidden()
      Returns the value of the hidden record component.
      Returns:
      the value of the hidden record component
    • creationTime

      public long creationTime()
      Returns the value of the creationTime record component.
      Returns:
      the value of the creationTime record component
    • lastModified

      public long lastModified()
      Returns the value of the lastModified record component.
      Returns:
      the value of the lastModified record component
    • lastAccess

      public long lastAccess()
      Returns the value of the lastAccess record component.
      Returns:
      the value of the lastAccess record component
    • size

      public long size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component