I am not sure if this is a correct way to use method overloading or there is a nicer/good other logic. I have those 4 cases which can be happened. Is there a limit for the methods count?
private ResponseEntity<ServiceResponse> handleResponse(ServiceResponse response, ServiceRequest request) {
return handleResponse(response, request, null, null);
}
private ResponseEntity<ServiceResponse> handleResponse(ServiceResponse response, ServiceRequest request, Exception e) {
return handleResponse(response, request, e, null);
}
private ResponseEntity<ServiceResponse> handleResponse(ServiceResponse response, ServiceRequest request, Header header) {
return handleResponse(response, request, null, correlation);
}
private ResponseEntity<ServiceResponse> handleResponse(ServiceResponse response, ServiceRequest request, Exception e, Header header) {
//logic//
}