PathHolder implements Serializable { @Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof PathHolder)) { return false; } PathHolder pathHolder = (PathHolder)object; if (Objects.equals(toString(), pathHolder.toString())) { return true; } return false; } PathHolder(Path path);  PathHolder(String pathString); @Override boolean equals(Object object); Path getPath(); @Override int hashCode(); @Override String toString();  }
@Test public void testEquals() { PathHolder pathHolder = new PathHolder(Paths.get("testFile")); Assert.assertTrue(pathHolder.equals(pathHolder)); Assert.assertFalse(pathHolder.equals(new Object())); Assert.assertTrue( pathHolder.equals(new PathHolder(Paths.get("testFile")))); Assert.assertFalse( pathHolder.equals(new PathHolder(Paths.get("anotherFile")))); }