Class ModuleInfoHash

java.lang.Object
com.netflix.module.ModuleInfoHash

public final class ModuleInfoHash extends Object
Reads, writes, and verifies detached module-info.hash files.
  • Method Details

    • read

      public static ModuleInfoHash read(Path path) throws IOException
      Reads a detached module hash file. Blank lines and lines beginning with # are ignored.
      Parameters:
      path - the hash file
      Returns:
      the hashes in the file
      Throws:
      IOException - if the file cannot be read or contains an invalid entry
    • write

      public void write(Path path) throws IOException
      Writes entries in coordinate order.
      Parameters:
      path - the destination file
      Throws:
      IOException - if the file cannot be written
    • get

      public Optional<ModuleHash> get(ModuleInfoHash.Coordinate coordinate)
      Returns the hash recorded for a coordinate.
      Parameters:
      coordinate - the coordinate to find
      Returns:
      the recorded hash, or an empty value
    • get

      public Optional<ModuleHash> get(String name)
      Returns the hash recorded for an unversioned module name.
      Parameters:
      name - the module name
      Returns:
      the recorded hash, or an empty value
    • get

      public Optional<ModuleHash> get(String name, String version)
      Returns the hash recorded for a module name and descriptor version.
      Parameters:
      name - the module name
      version - the module version
      Returns:
      the recorded hash, or an empty value
    • verify

      public boolean verify(ModuleReference reference) throws IOException
      Tests whether a module has the hash recorded for the coordinate reported by its descriptor.
      Parameters:
      reference - the resolved module
      Returns:
      true if an entry exists and matches the module content
      Throws:
      IOException - if the module cannot be read
    • verify

      public boolean verify(String name, String version, ModuleReference reference) throws IOException
      Tests whether a module has the hash recorded for its name and version.
      Parameters:
      name - the module name
      version - the module version
      reference - the resolved module
      Returns:
      true if an entry exists and matches the module content
      Throws:
      IOException - if the module cannot be read
    • keys

      Returns the recorded coordinates.
      Returns:
      an unmodifiable set of coordinates
    • hashForKey

      public Optional<ModuleHash> hashForKey(ModuleInfoHash.Coordinate key)
      Returns the hash recorded for a coordinate.
      Parameters:
      key - the coordinate to find
      Returns:
      the recorded hash, or an empty value
    • covers

      public boolean covers(ModuleInfoHash observed)
      Tests whether all observed entries occur unchanged in this set.
      Parameters:
      observed - the entries that must be covered
      Returns:
      true if every observed entry is present and equal
    • differences

      public List<String> differences(ModuleInfoHash observed)
      Describes entries which are missing, no longer observed, or changed.
      Parameters:
      observed - the resolved entries to compare
      Returns:
      immutable descriptions ordered by coordinate
    • size

      public int size()
      Returns the number of recorded coordinates.
      Returns:
      the entry count
    • equals

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

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

      public static ModuleInfoHash.Builder newBuilder()
      Creates an empty hash-set builder.
      Returns:
      a new builder