Java: general function X->Y interface

Unfortunately, there's no such thing in the core Java libraries. As a consequence, many libraries define their own function-like interface. If you happen to use such a library already, you can re-use the function it uses.