RelativeFile { @Override public String toString() { return Objects.toStringHelper(this) .add("base", mBase) .add("file", mFile) .add("path", mOsIndependentRelativePath) .toString(); } 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 relativeFileToString() { File base = new File("basic"); File relative = new File(new File(base, "foo"), "bar"); String toString = new RelativeFile(base, relative).toString(); assertTrue(toString.contains("basic")); assertTrue(toString.contains("foo/bar")); }