Hello,
does anybody know how to put a constant value into an attribute with dozer? I haven't seen anything about that in the dozer's documentation
Hello,
does anybody know how to put a constant value into an attribute with dozer? I haven't seen anything about that in the dozer's documentation
Not entirely sure what you mean - if you want Dozer to always populate BeanB.someField with a constant whenever you map from BeanA to BeanB?
You might want to register a custom converter for this mapping.
How about taking advantage of the events mechanism?
So you could register a listener which would do the setting of the value in mappingFinished()
of your listener.
Consult dozer doc on events for details. Of course you would have to guard the setting code with some kind of if ... instanceof
condition.
Recent builds of dozer make this easier. You can specify both custom converters and you can specify parameters to that converter for a given field mapping. It should be trivial to create a single 'ConstantConverter' that will take an input parameter and put that in the output field 100% of the time.