Wait One Minute…
Sometimes as I refactor code I look at my changes and think, wait one minute… as I was refactoring my ExtractorFactory, trying to reduce the boilerplate code, I realized that I could slice away an entire layer of code.
I was working on the redundant exception handling code in the Extractors:
To solve that I introduced a ThrowingBiFunction based on this article:
And started replacing the BiFunctions I’d written:
In doing so it occurred to me … what the heck?! So I instead changed the interface on the ExtractorFactory to:
Then there was no need for predefined Extractors, instead using the factory code could simply read:
Much nicer. Look for the entire project on github.