I want to create a rest to communicate between server and client.
The constructor given below:
public class RestHelper {
public Rest
I got the solution.
ResultContainData<Boolean> result = new ResultContainData<>();
RestHelper<User, ResultContainData<Boolean>> helper = new RestHelper<>(url, user, (Class<ResultContainData<Boolean>>)result.getClass());
It's working for me. I am still looking for a better solution.
You can only learn the value of I and R by capturing them in a subclass definition - otherwise they are erased at runtime. Ex:
class MyStringRestHelper extends RestHelper<String, String> {
Then using something like TypeTools you can resolve the values of I and R:
Class<?>[] typeArgs = TypeResolver.resolveRawArguments(RestHelper.class, MyStringRestHelper.class);
Class<?> i = typeArgs[0];
Class<?> r = typeArgs[1];
assert i == r == String.class;