
com.github.dakusui.floorplan.resolver.Mapper Maven / Gradle / Ivy
package com.github.dakusui.floorplan.resolver;
import com.github.dakusui.floorplan.component.Attribute;
import com.github.dakusui.floorplan.component.Configurator;
import com.github.dakusui.floorplan.policy.Policy;
import java.util.function.Function;
import java.util.function.Supplier;
public interface Mapper extends Function, Function>> {
default R apply(Configurator configurator, Policy policy, T value) {
return this.apply(configurator).apply(policy).apply(value);
}
static Mapper of(Function, Function>> func) {
return of(func, () -> "Mapper(noname)");
}
static Mapper of(Function, Function>> func, Supplier messageSupplier) {
return new Mapper() {
@Override
public Function> apply(Configurator aConfigurator) {
return p -> t -> func.apply(aConfigurator).apply(p).apply(t);
}
@Override
public String toString() {
return messageSupplier.get();
}
};
}
static Mapper create(Function func) {
return of(c -> p -> func);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy