com.noleme.flow.connect.text.transformer.BasicTokenMapping Maven / Gradle / Ivy
The newest version!
package com.noleme.flow.connect.text.transformer;
import com.noleme.flow.actor.transformer.Transformer;
import java.util.Collection;
import java.util.function.Function;
import java.util.stream.Collector;
/**
* @author Pierre Lecerf ([email protected])
* Created on 2020/12/17
*/
public class BasicTokenMapping , CO extends Collection> implements Transformer
{
private final Function mapper;
private final Collector collector;
public BasicTokenMapping(Function mapper, Collector collector)
{
this.mapper = mapper;
this.collector = collector;
}
@Override
public CO transform(CI tokens)
{
return tokens.stream()
.map(this.mapper)
.collect(this.collector)
;
}
}