I am working in a SpringBoot project.
In my model class I have a enum type property:
public class Car {
CarType type;
...
}
The enum CarType:
public enum CarType {
SEDAN, HATCHBACK, SUV
}
In my DTO layer, the payload of request should tell the car type, normally it uses String type to indicate car type:
public class RequestPayload {
String carType;
...
}
But if I define it as enum type:
public class RequestPayload {
CarType carType;
...
}
I wonder is there a way to directly map the value from json to enum type value?