import java.util.List; import java.util.function.Function; import static java.util.Collections.singletonList; class Main { public static void main(String[] args) { FlatMap flatmap = new FlatMap<>(); Col s1 = new Col<>(); Col s2 = s1.apply(flatmap.with((String word) -> singletonList(new Item()))); Col s22 = s1.apply(flatmap.with((word) -> singletonList(new Item()))); } } class FlatMap implements Transform, Col> { FlatMap with(Function> fn) { return new FlatMap<>(); } } class Col { Col apply(Transform, Col> transform) { return new Col<>(); } } interface Transform { } class Item { }