Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to configure Dozer such that by default fields are rather accessed directly that through setter-/getter method

I have to map a complex structure of Java classes which don't expose their fields through set-/get-methods in general (this is given and can't be changed). So mapping can only be performed on a direct field access. Dozer allows individual fields to be made accessible but I haven't found a setting to make this the general behaviour. As a result I wouldn't have to map each field explicitly just for making it accessible!

Does this option exist? - On a class level? - On a global level?

like image 777
Martin Ahrer Avatar asked Sep 11 '12 13:09

Martin Ahrer


1 Answers

You can set it on a class level.

<mapping>
   <class-a is-accessible="true">MyClass</class-a>
   ...
</mapping>

From the Dozer XSD:

is-accessible Indicates whether Dozer bypasses getter/setter methods and accesses the field directly. This will typically be set to "false". The default value is "false". If set to "true", the getter/setter methods will NOT be invoked. You would want to set this to "true" if the field is lacking a getter or setter method.

like image 59
Alex Vayda Avatar answered Oct 07 '22 11:10

Alex Vayda