private static Annotation [ ] findPropertyAnnotations ( Class < ? > clazz , String propertyName , boolean useRead ) throws IntrospectionException { PropertyDescriptor propertyDescriptor = getPropertyDescriptor ( clazz , propertyName ) ; if ( propertyDescriptor == null ) { return new Annotation [ ] { } ; } Method accessMethod = null ; if ( useRead ) { accessMethod = propertyDescriptor . getReadMethod ( ) ; } else { accessMethod = propertyDescriptor . getWriteMethod ( ) ; } if ( accessMethod != null ) { Annotation [ ] annotations = accessMethod . getAnnotations ( ) ; return annotations ; } else { return new Annotation [ ] { } ; } }
Find annotation given a particular property name and clazz . This figures out the writeMethod for the property and uses the write method to look up the annotation .