RFR: 8285452: Add a new test library API to replace a file content using FileUtils.java [v7]
Weijun Wang
weijun at openjdk.java.net
Fri Apr 29 18:32:40 UTC 2022
On Fri, 29 Apr 2022 14:19:40 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> The comparison is intentionally made lax so the caller does not need to provide the exact indentation or even new line characters. We think along with `fromLine` and `toLine` this is enough to make sure we are not modifying the wrong lines.
>
> Shouldn't the comparison be better implemented by the caller then, who will know whether spaces are important or not? That's why I had suggested taking a `Predicate<String>` that could be called with each line removed, and the caller could interrupt the parsing by returning false when they detect a mismatch with what they expect.
We can provide a more sophisticated `Function<String,String>` replacer if we want to let user to customize all the details. This time we still only want them to be string literals. I agree we can keep the new lines inside, but trimming on each line and the final block is still useful so caller does not need to care about indentation and empty lines at both ends.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8360
More information about the core-libs-dev
mailing list