I have a method called createTuxedoResponse which will receive a model object that inherits from the BaseRequestModel class, but as a second parameter it will receive a class ( .class ) same that does NOT inherit from BaseRequestModel , how specific that T of Class<T>
refers to another type of class that does not inherit from BaseRequestModel .
Note: It does not work with Class<?>
since later I need to make a cast and if I use this, it will not let me cast.
private <T extends BaseRequestModel> String createTuxedoResponse(T model, Class<T> responseClass) {
String tuxedoResponse = null;
try {
tuxedoResponse = mapper.writeValueAsString(ciService.createTuxedoResponseModel(model, responseClass));
} catch (JsonProcessingException e) {
LOG.error(e.getMessage());
e.printStackTrace();
}
return tuxedoResponse;
}