I am porting C++ application to java and I have a problem with Genric method.
I have generic class which should implement functionality depending on template argument.
T should wrap plenty of different types of types and they differe in way to stream. Only method which is specific to each type is "saveToStream".
In C++ it is very easy:
As a solution I have created set of saveToStream() methods (for every type of parameter) and the same set of subclasses of generic class. It is "ugly" comparing to C++. Is there something more elegant?