Jibx generating toString method

300 Views Asked by At

I'm currently using the Jibx maven plugin to codegen Java POJOS from a defined schema. The code gets generated fine, but what I want is for the toString method to be generated too. As I am round tripping from Schema to Classes I cant manually define the toString method as this will get overwritten when I re-generate. And I don;t want to create a wrapper class just for the toString methods.

Is there a flag option or something somewhere to say I want the toString method to be generated??? I've looked at the Jibx documentation online and could not find a straight simple answer to the above.

Any help would be very much appreciated.

thanks so much

1

There are 1 best solutions below

0
On

user983022,
There is no automatic way to add code to a generated java clas in JiBX, but...
You have several options to solve this problem:

  1. Override your generated class and add the toString() method. (Easiest)
  2. Manually modify the generated code and then bind it with JiBX. (Breaks if the schema changes in the future)
  3. Add a maven plugin to modify the source code between the code generation and the binding step. I'm sure there's a sed-like plugin that can do this... if not, it would be easy to write. (You have to find/write a plugin that can do this)

I Hope this helps!

Don
JiBX Maven plugin author