I have a simple Spring Boot application which accepts various event types. I have put a validation on the controller to check against those Event types. If Event Type does not match the Enum from the calling Client App, i throw an exception. However if the Value matches one of the event i want to retrieve that value and do a custom logic from Controller to Service Class. Any idea on how it can be done. Here is the Rest Controller and Enum Class.
public enum EventTypes {
ADDONE("AddOne"),
DELETEONE("DeleteOne"),
ADDTWO("AddTwo"),
DELETETWO("DeleteTwo");
private String event;
private EventTypes(String event){
this.event = event;
}
}
Rest Controller:
@PostMapping(value = "/eventProcess", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public GenericResponse produceEventMessage(
@Parameter(in = ParameterIn.QUERY, description = "", required = true)
@RequestParam(value = "eventType", required = true) EventTypes eventType,
@Valid @RequestBody MessageRequest messageEventRequest) {
LOG.info("Event Type ::::" + eventType); // I need to retrieve this value
... Remaining Business Logic to be executed
}
Client Application URL : http://localhost:8080/eventProcess?eventType=AddOne