Is there a way to use annotations in Java to replace accessors?

前端 未结 7 1110
旧时难觅i
旧时难觅i 2020-12-14 22:50

I\'m a little new to the Java 5 annotations and I\'m curious if either of these are possible:

This annotation would generate a simple getter and setter for you.

相关标签:
7条回答
  • 2020-12-14 23:40

    The @attribute you are referring too cant work with annotations as they are now in Java (as jamesh pointed out).

    What you are probably looking for is "properties" which dont exist yet in Java. But is is a very hot topic right now, and we might get them in Java 7 or maybe Java 8 (as I am still stuck on 1.4.2 it wont help me, but it might help you).

    There was an interesting discussion allusion to implementing properties with annotations in the Java Posse episode #219.

    0 讨论(0)
提交回复
热议问题