I am working on a small library that emulates the values of the values returned by multiple values in streams. For this to work well, I would like to use StreamTuple::newinstead of StreamTuple::createor id -> new StreamTuple<>(id, id). I tried various modifications, but my generics-fu are not good enough to understand how to change the source to allow this.
public class StreamTuple<L, R> {
protected final L left;
protected final R right;
public StreamTuple(L left, R right) {
this.left = left;
this.right = right;
}
public static <L> StreamTuple<L, L> create(L left) {
return new StreamTuple<>(left, left);
}
....
Call code snippet:
Map<String, String> m = Stream.of("1", "2", "3")
.map(id -> new StreamTuple<>(id, id))
.collect(toMap(StreamTuple::left, StreamTuple::right));
Suggestions? Or can not be done?
EDIT: , StreamTuple, L R . , , , . , L/R, - . ?