开发者

Java Property Annotation Standard/Library

开发者 https://www.devze.com 2023-01-06 09:55 出处:网络
I am trying to create a library which depends heavily on开发者_运维百科 annotating class properties. The properties should be able to be annotated via getters or on the actual underlying fields (ala J

I am trying to create a library which depends heavily on开发者_运维百科 annotating class properties. The properties should be able to be annotated via getters or on the actual underlying fields (ala JPA etc.)

Is there some standard for this? Tons of libraries do this (e.g. Hibernate). Do they all just roll their own implementation and conventions? Is there a good library which makes this easy? It seems as though there should be some standard for this.

I could easily just reflect through all of a class's methods and fields and check for the presence of an annotation, but there are lots of subtleties (e.g. "get" or "is" prefixes on getter methods). Anyone have any ideas?


I would check the Pluggable Annotation Processing framework.

See

  • Annotation Processing: The Pluggable Annotation Processing API
  • Annotation Processing Tool (apt)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号