I am currently working with Java 8 and using functional interfaces a lot. I often find myself writing code like this:
public interface MessageHandler extends Consumer<String> { }
Is this a good idea or an indicator of me abusing functional interfaces to make Java feel more like C#?
Edit: Maybe to expand a little:
public class MessageGenerator {
public void registerMessageHandler(MessageHandler handler) {
// [...]
public interface MessageHandler extends Consumer<String> { }
}
registerMessageHandler((str) -> doSomething(str))one way or the other, no? Where is it that you benefit from having aliased theConsumer? Finding usages? – Konrad Morawski Mar 23 '15 at 09:19