UnemployedNinja
Thread.sleep in a constructor
It's used to create a websocket client. The server I'm connecting to has a service API, which is used to get the websocket server for different regions. And the websocket client requires a URL to be created
I could just contact the service API before, and then create the client, but I'd like to do it all in one
14 replies
Struggling with generic class... design?
In short, my aim is to somehow only have one declaration of the
T JsonDeserialize
method, without affecting how BaseClass
is used/accessed and without having to rewrite the same method and annotations 50 times4 replies
Struggling with generic class... design?
My first thought was to make
BaseClass
a generic type, so I can have the following static method:
But this brings in two problems that I'd prefer to avoid:
1. I can't make a generic instance of BaseClass
anymore and will always have to specify the type.
2. I always have to specify the type when checking if something is an instance of BaseClass
.
My next attempt was to make a typed version of BaseClass
which the generic version will extend from, end then other classes from that:
Now I can access MyClassA.JsonDeserialize(json)
, however, MyClassA
doesn't have access to all of the constructors from BaseClass
. Meaning I'd have to duplicate, and rewrite them into BaseClass<T>
, along with any annotations - dumb idea.
I have a feeling the only way I can get what I want is by writing the JsonDeserialize
method into every class that extends BaseClass
4 replies