Class EnumUtils
java.lang.Object
com.baomidou.mybatisplus.core.toolkit.EnumUtils
Utility methods for MyBatis-Plus enum metadata and value conversion.
- Since:
- 2026-07-01
- Author:
- hubin
-
Method Summary
Modifier and TypeMethodDescriptionfindEnumValueFieldName(Class<?> clazz) Finds the field annotated with@EnumValue.static ObjectGets the configured persistent value of an enum constant.static booleanWhether the class is an MP enum declared byIEnumor@EnumValue.static EnumMetadataGets cached metadata for an MP enum.static ObjectnormalizeValue(Object value) Normalizes enum values and JDBC values into stable comparison keys.static <E extends Enum<E>>
EResolves an enum constant by persistent value.
-
Method Details
-
metadata
Gets cached metadata for an MP enum.- Parameters:
enumClassType- enum class- Returns:
- enum metadata
-
findEnumValueFieldName
Finds the field annotated with@EnumValue.- Parameters:
clazz- class- Returns:
- enum value field name
-
isMpEnums
Whether the class is an MP enum declared byIEnumor@EnumValue.- Parameters:
clazz- class- Returns:
- true if the class is an MP enum
-
getValue
Gets the configured persistent value of an enum constant.- Parameters:
parameter- enum constant- Returns:
- persistent value
-
valueOf
Resolves an enum constant by persistent value.- Type Parameters:
E- enum type- Parameters:
enumClassType- enum classvalue- persistent value- Returns:
- enum constant, or null when value does not match
-
normalizeValue
Normalizes enum values and JDBC values into stable comparison keys.- Parameters:
value- raw value- Returns:
- normalized value
-