Replacing interface with a general Consumer (adapted from Java 8)