Multiple return types

Today I had this little problem: I have JMS messages with common properties, and some properties set depending on message type. I want to handle all the common properties in a specific method so I don’t need to duplicate code. How can I return different types from the same method!? Is this even possible in […]

Callable and Supplier
– never shall the two meet!?

Let’s say we have this clever little legacy API method:

Now, we discover Java 8’s neat Supplier functional interface. As a courtesy to our users, we decide we would like to accept those as well. Does this work? A naïve addition gives us:

So far so good? Well, what happens if we try […]