Added draft v1 of jaxb contract first#532
Added draft v1 of jaxb contract first#532garethahealy merged 2 commits intoDozerMapper:masterfrom garethahealy:jaxb
Conversation
orange-buffalo
left a comment
There was a problem hiding this comment.
@garethahealy I have preliminary checked the code, looks very good to me. There is one important comment about Lombok. If you could have a look and provide your feedback, I would then continue the review.
|
|
||
| DozerBeanMapper mapper = (DozerBeanMapper)factory.getObject(); | ||
| List<?> files = mapper.getMappingFiles(); | ||
| //List<?> files = mapper.getMappingFiles(); |
There was a problem hiding this comment.
It makes sense to handle this commented code to not forget about it. Maybe some todo could help here, if changing the test is not feasible in the first iteration.
There was a problem hiding this comment.
Not sure why that was commented out. Have uncommented and test still works.
| <id>schemagen</id> | ||
| <phase>generate-resources</phase> | ||
| <goals> | ||
| <goal>schemagen</goal> |
There was a problem hiding this comment.
I remember last time we had a discussion about using Lombok in model classes, to remove those boilerplate getters, setters and toStrings, but after adding Lombok the build was failing. I created a mojohaus/jaxb2-maven-plugin#88 to address this, but did not get any response yet.
But, I was able to add Lombok and build the project with previous major version of the jaxb2 plugin (they rewrote a lot in 2x). In my opinion, clean code in core is more important than using the latest maven plugin version, thus I would recommend to apply this solution.
In order to build with lombok, I changed the jaxb2-maven-pluginversion to 1.6 and its execution configuration to the following:
<execution>
<id>schemagen</id>
<phase>generate-resources</phase>
<goals>
<goal>schemagen</goal>
</goals>
<configuration>
<workDirectory>${project.build.directory}/generated-resources/schemagen</workDirectory>
<includes>
org/dozer/builder/model/jaxb/**
</includes>
<transformSchemas>
<transformSchema>
<uri>http://dozermapper.github.io/schema/bean-mapping</uri>
<toFile>bean-mapping.xsd</toFile>
</transformSchema>
</transformSchemas>
</configuration>
</execution>
<execution>
<id>xjc</id>
<phase>generate-test-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>
${project.basedir}/src/test/xsd/jaxb
</schemaDirectory>
<packageName>org.dozer.vo.jaxb.employee</packageName>
<outputDirectory>target/jaxb-sources</outputDirectory>
</configuration>
</execution>
After that the plugin generated the XSD from classes with Lombok annotations applied.
There was a problem hiding this comment.
Done. have gave the model classes a lombok once over
| dozerClass.setMapGetMethod(mapGetMethod); | ||
| dozerClass.setMapSetMethod(mapSetMethod); | ||
| dozerClass.setCreateMethod(createMethod); | ||
| dozerClass.setMapNull(mapNull == null ? null : mapNull); |
There was a problem hiding this comment.
Maybe we could just pass the mapNull as the result of ternary operator will be always equal to the mapNull?
| */ | ||
| @Override | ||
| public List<MappingFileData> build(BeanContainer beanContainer, DestBeanCreator destBeanCreator, PropertyDescriptorFactory propertyDescriptorFactory) { | ||
| List<MappingFileData> answer = new ArrayList<MappingFileData>(); |
There was a problem hiding this comment.
We could cleanup a bit here and use the diamond operator.
|
@orange-buffalo ; any further comments regarding review? |
orange-buffalo
left a comment
There was a problem hiding this comment.
Looks good to me.
This PR:
This feature wont be abled by default for a few releases, just to make sure nothing has been broken.
CC @orange-buffalo for code review.