What below settings means (jaxb-fluent-api)?

I have a setting in my POM file. Especially jaxb-fluent-api configuration.

<plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <configuration> <extension>true</extension> <args> <arg>-Xfluent-api</arg> </args> <schemaDirectory>src/main/resources</schemaDirectory> <plugins> <plugin> <groupId>net.java.dev.jaxb2-commons</groupId> <artifactId>jaxb-fluent-api</artifactId> <version>2.1.8</version> </plugin> </plugins> </configuration> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> 

Without jaxb-fluent-api configuration, entities can be generated from xsd. here is what benifits using jaxb-fluent-api ?

Thanks!

+4
source share
1 answer

jaxb-fluent-api is a JAXB extension that allows you to generate free api-style code. Now, a free api is a way to develop your class methods, so they always return this instead of void .

There is a good example on the project wiki (I shortened it a bit for brevity, check the site for a complete example):

Normal JAXB generated code should be used as follows:

 Project project = factory.createProject(); project.setModelVersion("4.0.0"); project.setGroupId("redmosquito") project.setArtifactId("jaxb-fluent-api-ext") project.setPackaging("jar") project.setVersion("0.0.1") project.setName("JAXB Fluent API Extensions"); 

With the jaxb-fluent-api extension, you can program the following:

 Project project = factory.createProject() .withModelVersion("4.0.0"); .withGroupId("redmosquito") .withArtifactId("jaxb-fluent-api-ext") .withPackaging("jar") .withVersion("0.0.1") .withName("JAXB Fluent API Extensions"); 

This is basically what the fluent api is talking about.

+4
source

All Articles