/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.test;

import java.util.function.Function;
import java.util.function.Supplier;
import net.ranides.assira.collection.maps.IdentMap;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class TAdapter<R,T> extends IdentMap<R, T> {
    
    public R map(T value, Function<T, R> adapter) {
        R key = adapter.apply(value);
        put(key, value);
        return key;
    }
    
    public Supplier<R> map(Supplier<T> supplier, Function<T, R> adapter) {
        return () -> map(supplier.get(), adapter);
    }
    
    public <V> Function<V, R> map(Function<V, T> generator, Function<T, R> adapter) {
        return (param) -> map(generator.apply(param), adapter);
    }
    
}
