com.github.dakusui.floorplan.resolver.Mapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of floorplan Show documentation
Show all versions of floorplan Show documentation
A library to model a heterogeneous and distributed software
system for testing
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);
}
}