Hello!
Thanks for developing MapStruct, it's a great idea!
There is just one remaining scenario I am trying to figure out:
There are cases where I need to map from Java classes that don't follow the getFoo() method JavaBeans naming convention, instead consistently lobbing off the "get" part. For example, can I automatically map from the following class to a class with matching "setName(String)" setter without having to define mappings explicitly (i.e via configuration annotation or similar)?
public class SourceClass {
private String name;
public SourceClass() {
}
public String name() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Thanks,
Scott
--
You received this message because you are subscribed to the Google Groups "mapstruct-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstruct-use...@googlegroups.com.
To post to this group, send email to mapstru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Gunnar,
Thanks for the quick reply. I agree relaxing the rules by default is not a good idea. Adding a configuration option to enable relaxed getter handling would be fantastic and most likely sufficient for everything I need to do. It might be overkill, but one way to handle all kinds of odd getter naming conventions explicitly is to provide a way to define custom rules programmatically, something like the NameTransformer + NamingConvention interfaces in ModelMapper.
Thanks,
Scott
On Thursday, November 27, 2014 3:08:49 PM UTC+9, Scott More wrote:Hello!
Thanks for developing MapStruct, it's a great idea! There is just one remaining scenario I am trying to figure out:
There are cases where I need to map from Java classes that don't follow the getFoo() method JavaBeans naming convention, instead consistently lobbing off the "get" part. For example, can I automatically map from the following class to a class with matching "setName(String)" setter without having to define mappings explicitly (i.e via configuration annotation or similar)?
public class SourceClass {
private String name;
public SourceClass() {
}
public String name() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Thanks,
Scott
--
Let me know if you need a different approach due to problems in the annotation processor context or other, I'm happy to try to come up with something different. I might have a few cycles to help on implementation or testing side too if that makes sense.
Thanks,
Scott
No problem. I did some hacking late in the week and got Executables doing the loose mapping correctly with non get-prefixed methods (e.g. foo() -> foo). So far everything seems straightforward in the code and build env.
Your comments on issue #365 all make sense. I do have one question: Would mapstruct-processor be dependent on the new mapstruct.spi artifact/jar? If not, how would you like that to work?
One simple way to give access to the default implementation is to have that default class in the mapstruct.spi artifact so users can just extend if desired.
I'm happy to take lead on this if that makes sense. My schedule is pretty tight for the next two weeks at least but I should have some time here and there to start in on a proper solution.
Thanks,
Scott