I have written custom JsonCreator for enum
@GetMapping(value = "/path/{pathVar1}")
public Response getValue(
@PathVariable String pathVar1,
@RequestParam(required = false, name = "type") MyEnum type)
Enum
@AllArgsConstructor
@Getter
public enum MyEnum {
A_12(Set.of("a", "12"));
private Set<String> aliases;
@JsonCreator
public static MyEnum forValues(@JsonProperty("type") String type) {
return Arrays.stream(MyEnum.values())
.filter(s -> s.getAliases().stream().anyMatch(a -> StringUtils.equalsIgnoreCase(a, type)))
.findFirst()
.orElseThrow(() -> new RuntimeException("aa"));
}
Its not considering jsoncreator for enum.
Caused by: java.lang.IllegalArgumentException: No enum constant MyEnum.12
Am I missing any thing.