The following Java 8 code passes a lambda to a function that defers execution of the generateMessage(...) function only if logging is enabled.
What would the equivalent Scala code look like?
producer.send(true, () -> generateMessage(1, "A Test Message"));
public void send(boolean enabled, Supplier<ProducerRecord> message) {
if (enabled) {
something.send(message.get())
}
}