-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom mappers which are SELMA mappers are not injected into the outer mapper #185
Comments
Hi, in this case XMapper is an abstract class so Selma does not know how to instantiate it by default. Selma.builder(YMapper.class).withCustom(Selma.mapper(XMapper.class)).build(); When the Custom Mapper is a class with default constructor available, Selma will instantiate it for you. |
Hi, Sorry for the long hiatus following this up. What I was suggesting was Selma to be a bit more proactive about finding the Mappers (with default constructor and/or Selma generated). Currently I'm using the following code to do that and it works out nicely. It would be nice if Selma does something like that: /**
static void injectCustomMappers(T mapper) { static List findCustomMappers(Class mapperClass) { static void injectCustomMapper(Object mapper, Class customMapperClass, Object customMapper) { |
If I understood the documentation correctly, the following should work:
However, I'm getting a NullPointerException because in the generated
YMapper
the custom mapperXMapper
is NULL.My understanding was that
Selma.build()
would inject aXMapper
instance in the generatedYMapper
instance.If using a custom mapper that is a concrete class with a default constructor the same is instantiated in the generated 'YMapper' class constructor.
So far the only solution I've found is to cast the YMapper to the generated class and set the an XMapper instance previously obtained. But this does not seem correct, not to mention that for composite Mappers I have to do it recursively and all using reflection as I cannot cast to a generated class because javac fails to find it.
The text was updated successfully, but these errors were encountered: