mapstruct
mapstruct copied to clipboard
Automatically detect camelCase and snake_case propreties.
Use case
Currently when mapping between 2 objects where field name only differ in their case styles like:
public class CamelCase {
Long id;
String someString;
}
public class SnakeCase {
Long id;
String some_string;
}
The mapper needs to be manually configured to associate someString and some_string.
Generated Code
No response
Possible workarounds
For now I'm manually defining @Mapping annotations for the fields:
@Mapping(target = "preparationTime", source = "preparation_time")
@Mapping(target = "menuCategoryId", source = "menu_category_id")
MapStruct Version
1.6.0.Beta1
@FancyBanana this can be achieved by using your own custom AccessorNamingStrategy. Have a look at Custom Accessor Naming Strategy for more information.
I am not sure that it is worth to do this automatically from MapStruct side.
What we could perhaps do is to have an alternative strategy and allow people to use that one through some configuration option.