简体   繁体   中英

Usage of @Generated annotation

I'm gonna ask may be a little philosophic question.

There's annotation in Java - @Generated .
I want to understand a good style of using it.

For example, if I've created implementation of Serializable and generated serialVersionUID in Eclipse.
- Do I need to put @Generated before the serial field or it's unnecessary fanaticism?
- If I do then for what purposes will it be used despite simple info for other developers?
- And finally, what code generator for "value" field I'm using here?
Thanks in advance!

  1. I would think this is unnecessary fanaticism regarding to a field.
  2. An IDE could make @Generated code readonly (since it's bad practice to hand-edit generated code) and/or remove warnings for it, but I do not know of any one doing it.
  3. When I put this annotation on Eclipse-generated methods (hashCode, equals, toString), I just put "Eclipse", although "org.eclipse.Eclipse" might be better.

Of course, the ideal would be Eclipse to put itself this annotation when it generates code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM