Parameterize a method with two inputs

1

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;
      }
    
asked by Aridai Solis 02.12.2018 в 06:46
source

1 answer

0
 private <T extends BaseRequestModel, S> String createTuxedoResponse(T model, Class<S> responseClass) { ... }
    
answered by 05.12.2018 в 20:33