How to solve provide parameterized type for this generic in SonarLint

9.3k Views Asked by At

I am trying to refactor my code using the IntelliJ idea extension called sonarLint. In there, sonarLint suggests further modification like this picture below(I have marked the issue in red)

SonarLint error alert

here is my code

 public class AbcController extends BaseController{   

    private final PermissionService permissionService;

    public PermissionController(PermissionService permissionService) {
        this.permissionService = permissionService;
    }

    @GetMapping("/groups")
    public ResponseEntity<List<GroupResponse>> getGroups( String accessToken) {
        List<GroupResponse> groupResponses = permissionService.getGroups(accessToken);       
        return getResponseEntity(groupResponses);
    }
}



public abstract class BaseController <T>{


    protected ResponseEntity<T> getResponseEntity(T t, HttpHeaders httpHeaders) {
        return new ResponseEntity<> (t, httpHeaders, HttpStatus.OK);

    }

    protected ResponseEntity<T> getResponseEntity(T t) {
        return new ResponseEntity<> (t, HttpStatus.OK);

    }
}

I tried to make modifications according to the sonarLint alert but it is not working. Please help me with this problem. Thank you all.

0

There are 0 best solutions below