Updated JavaBean specification to reflect existence of annotations

I thought it should be obvious, but I can't find it.

Now that the fields can contain annotations, I thought this should be reflected in the JavaBean spec, but I cannot find it.

What I mean:

JavaBean is a specification that allows you to treat objects in a uniform way by exposing their properties and then reading and writing them.

Since POJO properties can now be annotated (for example in Hibernate annotations), I expected annotations to be available using the JavaBean specification - to discover more metadata than just the type of the property.

Or should I resort to a getter method trick and find the metadata using the simple reflection API?

+2


source to share


1 answer


You can access getter and setter methods using the PropertyDescriptor class in the Java Beans API. Annotations for these methods are available from getReadMethod () and getWriteMethod (). At the end of the day, this is slightly different from the Java Beans API and the Reflection API.



+4


source







All Articles