Closed GoogleCodeExporter closed 9 years ago
Would your need be accomplished if you were able to customize the behavior of
ClassMapBuilder#byDefault()?
Original comment by matt.deb...@gmail.com
on 19 Jul 2012 at 12:34
I do not quite understand. ClassMapBuilder provides mapping for a particular
class.
factory.registerClassMap(ClassMapBuilder.map(Entity1.class,Dto1.class)
...
.toClassMap());
factory.registerClassMap(ClassMapBuilder.map(Entity2.class,Dto2.class)
...
.toClassMap());
...
and so on
But, I have to develop api which doesn't demand registrate every DTO.
If I could change behaviour "public ClassMapBuilder<A, B>
byDefault(DefaultFieldMapper... defaults)" globally for all instances of
ClassMapBuilder.class, than maybe yes, my need would be accomplished.
Original comment by dkhomya...@gmail.com
on 19 Jul 2012 at 12:01
Ok, let me clarify: ClassMapBuilder#byDefault() can be called manually, but it
is also the method used internally by Orika when you try to map a pair of types
which have not yet been registered.
Essentially, Orika does this on this fly:
ClassMapBuilder.map(UnmappedA.class,UnmappedB.class)
.byDefault()
.toClassMap());
So, if you were in control of the byDefault() method, you'd be controlling
exactly how the classes are mapped on the fly.
Does this make sense now?
Original comment by matt.deb...@gmail.com
on 19 Jul 2012 at 4:11
I see. In customization of byDefault() I'll be to parse target classes's
anatations and registrate field- mapping. It would be nice.
Original comment by dkhomya...@gmail.com
on 19 Jul 2012 at 4:59
Please check now in the 1.2.0 branch; with the most recent changes,
ClassMapBuilder can be extended.
To do this, you should also extend ClassMapBuilderFactory--override the
'newClassMapBuilder' method to return your own extension of ClassMapBuilder.
Then, you can set this factory to be used by the DefaultMapperFactory; use the
'classMapBuilderFactory()' method on DefaultMapperFactory.Builder to have your
ClassMapBuilderFactory be used by the 'classMap()' methods on
DefaultMapperFactory.
If you have some time, please let me know how if this resolves your issue...
Original comment by matt.deb...@gmail.com
on 18 Aug 2012 at 12:47
Original comment by matt.deb...@gmail.com
on 18 Aug 2012 at 12:51
I've checked 1.2.0 branch. The solution works fine and resolves my issue.
Probably, you should add getters of private fields
ClassMapBuilderFactory(propertyResolver, defaults) and ClassMapBuilder
(defaults). Because I must have access to them in my extensions. While I
override setters for saving reference to them.
Original comment by dkhomya...@gmail.com
on 20 Aug 2012 at 2:19
Thanks s lot!
Original comment by dkhomya...@gmail.com
on 20 Aug 2012 at 2:23
Glad to help.
Also, getters have been added for the two fields you asked about
(propertyResolver and defaults).
Original comment by matt.deb...@gmail.com
on 3 Sep 2012 at 9:35
Fixed in 1.2.0 release.
Original comment by matt.deb...@gmail.com
on 7 Sep 2012 at 9:54
Original issue reported on code.google.com by
dkhomya...@gmail.com
on 16 Jul 2012 at 7:47