blob: 3cbe1030e439882ae4303d5e49b3d5eee538798d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package bjc.utils.parserutils.splitter;
import java.util.function.UnaryOperator;
import bjc.funcdata.IList;
/**
* A token splitter that performs a transform on the tokens from another
* splitter.
*
* @author bjculkin
*
*/
public class TransformTokenSplitter implements TokenSplitter {
private TokenSplitter source;
private UnaryOperator<String> transform;
/**
* Create a new transforming splitter.
*
* @param source
* The splitter to use as a source.
*
* @param transform
* The transform to apply to tokens.
*/
public TransformTokenSplitter(TokenSplitter source, UnaryOperator<String> transform) {
this.source = source;
this.transform = transform;
}
@Override
public IList<String> split(String input) {
return source.split(input).map(transform);
}
}
|