RelativeFile { @Override public boolean equals(Object obj) { if (!(obj instanceof RelativeFile)) { return false; } RelativeFile rf = (RelativeFile) obj; return Objects.equal(mBase, rf.mBase) && Objects.equal(mFile, rf.mFile); } RelativeFile(@NonNull File base, @NonNull File file); @NonNull File getBase(); @NonNull File getFile(); @NonNull String getOsIndependentRelativePath(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Function<RelativeFile, File> EXTRACT_BASE; static Function<RelativeFile, File> EXTRACT_FILE; static Function<RelativeFile, String> EXTRACT_PATH; }
@Test public void relativeFileNotEqualsIfDifferentFile() throws Exception { File base = new File("base"); File relative = new File(base, "relative"); RelativeFile rf1 = new RelativeFile(base, relative); RelativeFile rf2 = new RelativeFile(base, new File("relative2")); assertFalse(rf1.equals(rf2)); }
@Test public void relativeFileNotEqualsIfDifferentBase() throws Exception { File base = new File("base"); File relative = new File(base, "relative"); RelativeFile rf1 = new RelativeFile(base, relative); File base2 = new File("base2"); RelativeFile rf2 = new RelativeFile(base2, new File(base2, "relative")); assertFalse(rf1.equals(rf2)); }