PathHolder implements Serializable { @Override public int hashCode() { String toString = toString(); return toString.hashCode(); } PathHolder(Path path);  PathHolder(String pathString); @Override boolean equals(Object object); Path getPath(); @Override int hashCode(); @Override String toString();  }
@Test public void testHashCode() { Path path = Paths.get("testFile"); String pathString = path.toString(); PathHolder pathHolder = new PathHolder(path); Assert.assertEquals(pathString.hashCode(), pathHolder.hashCode()); }