All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dakusui.floorplan.resolver.Mapper Maven / Gradle / Ivy

Go to download

A library to model a heterogeneous and distributed software system for testing

There is a newer version: 5.1.1
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy