Class NamedFile

Object
NamedFile

public final class NamedFile extends Object
A file with an associated unique name.

This is an immutable class.

The name is intended to be a compact unique identifier for a file (in a particular context).

Author:
Owen Feehan
  • Constructor Details

    • NamedFile

      public NamedFile(String identifier, File file)
      Create with an identifier and a file.
      Parameters:
      identifier - unique identifier associated with the file.
      file - the file.
  • Method Details

    • getPath

      public Path getPath()
      The path of getFile().
      Returns:
      the path
    • mapIdentifier

      public NamedFile mapIdentifier(BiFunction<String,File,String> function)
      Immutably renames the file, by assigning it a new identifier.
      Parameters:
      function - generates a new identifier from the existing identifier and file
      Returns:
      a newly created file with the assigned identifier, but existing file.
    • toPath

      public Path toPath()
      Returns:
      the path associated with the file.
    • getIdentifier

      public String getIdentifier()
      Unique identifier associated with the file.
    • getFile

      public File getFile()
      The file.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object