private Set < Annotation > getFieldAnnotations ( final Class < ? > clazz ) { try { return new LinkedHashSet < Annotation > ( asList ( clazz . getDeclaredField ( propertyName ) . getAnnotations ( ) ) ) ; } catch ( final NoSuchFieldException e ) { if ( clazz . getSuperclass ( ) != null ) { return getFieldAnnotations ( clazz . getSuperclass ( ) ) ; } else { logger . debug ( "Cannot find propertyName: {}, declaring class: {}" , propertyName , clazz ) ; return new LinkedHashSet < Annotation > ( 0 ) ; } } }
Private function to allow looking for the field recursively up the superclasses .