I have the following controller:
public interface SaveController {
@PostMapping(value = "/save")
@ResponseStatus(code = HttpStatus.CREATED)
void save(@RequestBody @Valid SaveRequest saveRequest);
}
SaveRequest corresponds to:
public class SaveRequest {
@NotNull
private SaveType type;
private String name;
}
and SaveType:
public enum SaveType {
DAILY, WEEKLY, MONTHLY;
}
The controller does not receive the enum itself, but a camelCase String. I need to convert that String into the corresponding enum. For instance:
dailyshould becomeDAILY.weeklyshould becomeWEEKLY.monthlyshould becomeMONTHLY.- Any other
Stringshould becomenull.
I've tried using the Spring Converter class, which does not work when the enum is inside an object (at least I don't know how to make it work in such times).
I honestly don't know what else to try