I'm not sure if this will help you, but I used it in the past to deserialize and return an object of the appropriate type.
public <T> T deserialize(String xml){ T object=null; ... //pull type information from method param ... return object=(T)type.newInstance(); //helper to instantiate class }
However, I'm not quite sure what you need to do. A simpler and clearer way to do this may be to create a converter interface for the data types you need and which classes should use it for implementation. Then what you need can be called directly on the object itself. eg:
inerface Convertor<T>{ T convert(); void set(T value); } class Something implements Converter<Long,ByteArray>{ ... public ByteArray convert(){...} public void set(ByteArray value){...} }
John kane
source share