com.meltmedia.dropwizard.jongo.Functions Maven / Gradle / Ivy
The newest version!
package com.meltmedia.dropwizard.jongo;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
class Functions {
static Supplier mapSupplier( Supplier supplier, Function mapping ) {
return ()->mapping.apply(supplier.get());
}
static Consumer consumerRequired(String name) {
return t->{throw new RuntimeException("Consumer "+name+" is required.");};
}
static Function functionRequired(String name) {
return u->{throw new RuntimeException("Function "+name+" is required.");};
}
static Supplier supplierRequired(String name) {
return ()->{throw new RuntimeException("Supplier "+name+" is required.");};
}
}