discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Custom class having a parameterized member class. #259

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Custom class having a parameterized member class.

What steps will reproduce the problem?
1.Create following class:

public abstract class RequestBuilder<TParameter, TResponse extends 
IJsonResponse>
{
    private void WriteRequestContent(Object SendObject) throws Exception
    {
        Gson serializer = new Gson();

        String data = null;

        if(ConnectRequest.class.isInstance(SendObject)) {
            data = serializer.toJson((ConnectRequest)SendObject);
        } else { ... }

        this.myWebRequest.setRequestProperty("Content-Length", data.length()+"");
        OutputStreamWriter wr = new OutputStreamWriter(this.myWebRequest.getOutputStream());
        wr.write(data);
        wr.flush();
        wr.close();
    }

    public class ConnectRequest
    {
        // Fields
        public ConnectHeader header;
        public String method;
        public TParameter parameters;

        // Methods
        public ConnectGroovesharkRequest(ConnectHeader myHeader, TParameter myParameter, String myMethod)
        {
            this.header = myHeader;
            this.parameters = myParameter;
            this.method = myMethod;
        }
    }
}
2.
Execute  ;)
3.
Error occurs

What is the expected output? What do you see instead?
Just to convert it to a json-string, instead i got "Expecting parameterized 
type, got class Base.RequestBuilder$ConnectRequest."

What version of the product are you using? On what operating system?
Gson 1.5;

What to do? :(

Original issue reported on code.google.com by scilor.hacker@googlemail.com on 27 Oct 2010 at 6:13

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 31 Oct 2010 at 2:40