1. Bean → Map
| Method |
Description |
| toSnakeCase(Object bean) |
Convert Bean to Map with snake_case keys; null values are omitted |
| toSnakeCaseWithNull(Object bean) |
Convert Bean to Map with snake_case keys; null values are preserved |
| toCamelCase(Object bean) |
Convert Bean to Map with camelCase keys; null values are omitted |
| toCamelCaseWithNull(Object bean) |
Convert Bean to Map with camelCase keys; null values are preserved |
2. Map Key-Value Operations
| Method |
Description |
| removeNulls(Map map) |
Remove all entries with null values (mutates the original Map) |
| filterNulls(Map map) |
Return a new Map with null-valued entries removed |
| putEntries(Map map, Object... keyValues) |
Batch-put key-value pairs (mutates the original Map) |
| withEntries(Map map, Object... keyValues) |
Batch-put key-value pairs and return a new Map |
| removeKeys(Map map, Object... keys) |
Remove specified keys (mutates the original Map) |
| excludeKeys(Map map, Object... keys) |
Remove specified keys and return a new Map |
| removeKeysIgnoreCase(Map map, Object... keys) |
Remove keys ignoring case |
| excludeKeysIgnoreCase(Map map, Object... keys) |
Remove keys ignoring case and return a new Map |
3. Map Key Naming Conversion
| Method |
Description |
| toSnakeCase(Map map) |
Convert all keys from camelCase to snake_case (e.g. userName → user_name) |
| toCamelCase(Map map) |
Convert all keys from snake_case to camelCase (e.g. user_name → userName) |
| toLowerCase(Map map) |
Convert all keys to lowercase |
example:
// Bean to snake_case Map
Map values = JooqMaps.toSnakeCaseWithNull(user);
values.remove("id");
// Add extra fields
JooqMaps.putEntries(values, "create_time", LocalDateTime.now());
// Filter null values
Map nonNull = JooqMaps.filterNulls(values);
// Remove keys
JooqMaps.removeKeys(values, "id", "create_time");
Top comments (0)