You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2008/01/02 02:41:40 UTC

The @SuppressWarnings on DataReaders and Writers

I'd like, at this point, to quote Alice in Wonderland on the subject of
serpents.

Note that I'm not actually messing with Databinding and DataReader and
DataWriter. I'm using the Aegis standalone API as petri dish.

I've read all the docs I can find on generics, and I've tried a whole
series of experiments.

I am now convinced that there's no such beast as:

<T> DataReader<T> createReader(Class<T> sourceType)

Why? because you can't get a Class object for DataReader<anything>, so
you can't cast to it.

You can have

<T,U> T createReader<Class<T> readerObject, Class<U> sourceObject)

Now, however, we can't define the output as an interface. It has to be a
specific class. What's the use of that?

This seems really silly to me, compared to just defining a set of
function:

DataReader<XMLStreamReader> createXMLStreamReader();
DataReader<Element> createElementReader();
and on down the line.

This, of course, doesn't permit the 'give me a list of classes on which
you can create readers'. 

If anyone out there knows generics better than I do and can write me
what I'm missing, I'm all eyes.