#421 Code Review of an Action Controller

Companies:
Vadarod
Themes:
SpringSpring CoreCode Review

Perform a code review:

@RestController
@RequestMapping(value = MappingPath.PROCESS, consumes = { MediaType.ALL_VALUE })
public class ProcessActionController {

    private final MailHandler mailHandler;
    private final ReportHandler reportHandler;

    @PostMapping(value = "/doAction")
    public ResponseEntity<Object> process(@RequestBody ActionRq request) {
        Action action = request.getAction();
        if (action == Action.SEND_MAIL) {
            return mailHandler.process(request);
        }
        if (action == Action.SEND_REPORT) {
            return reportHandler.process(request);
        }
        return ResponseEntity.ok().body(UserRs.getDefaultFallbackResponse());
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in