-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config option to choose commons-lang3 for hashCode/toString implementation #140
Comments
Good point about commons-lang. 2.x is getting quite long in the tooth now and I think a configuration property to choose the commons-lang version would be a good addition. I'll add this. Regarding the annotations, this has actually been raised before (#107) but I have so far not been able to think of a clean way to do this. One way is to indicate in the schema what annotations would be required (e.g. an extension property like
EDIT: forget that, Java's |
I understand the difficulty on finding a clean way to preserve existing annotations. It is not too much of a problem however. At least with the plugin I wrote which puts the generated source in a target directory. On initial generation I just copy the files to the main/java/src directory, and then when I make updates, I just do a compare (in eclipse) between the re-generated file and the actual source file. The eclipse compare makes it easy to merge in the changes. A real bonus however would be the ability to pepper the generated source with javax.validation constraints. Also it is too bad that there is not a standard @description annotation. It would be nice to be able to use @description annotations on all fields and places corresponding to the description attribute in json schema. |
One possible auto merging solution might be to leverage reflection during the generation process. If for example you knew you were going to generate a com.foo.bar.Baz class, you might be able to use a java class loader to look for an existing com.foo.bar.Baz class in the classes directory, load it up and use reflection to identify any additional annotations that might exist on the fields methods and properties. You could then include these extra annotations in the generated output. This presumes of course that the maven plugin is being used in something other than a standard build cycle and is being executed at development time. I also like your idea of using an extension property in the json schema itself I could imagine for example a property such as: |
I'm going to use this ticket to cover the 'choose commons-lang version' feature. We can pick up the custom-annotations stuff in #107 if necessary. Thanks again for your comments! |
One of the things I found troublesome was the fact that there was no way to have your POJO objects depend on Commons Lang3 versus Commons Lang without changing the import statements post generation.
Another thing I would like to see is the ability to edit the generated code with annotations and have the changes to the schema merged in.
For example if i have a pojo with the field:
@id
@JsonProperty("foo")
String id;
Note the @id field was added manually.
It would be great if post re-generation or update to schema that the manually added annotations were preserved wherever possible.
The text was updated successfully, but these errors were encountered: