Description
As per discussion with aljoscha
A very good and type safe way to supply type hints would be the following:
Define a hint class that takes a generic parameter.
public abstract class TypeHint<T> {}
The hints would have the following method:
public DataSet<T> returns(TypeHint<T> hint);
It would be used like this:
DataSet<Sting> data = ...; data .flatMap( (String str, Collector<Integer> out) -> out.collect(str.length()) ) .returns( new TypeHint<Integer>() {})
This would create an inline subclass of the hint, from which the type could be extracted. The generics would ensure that it is typesafe.