public static List < ReflectedInfo > getExposedFieldInfo ( final Class < ? > clazz ) { List < ReflectedInfo > results = null ; try { results = fieldInfoCache . get ( clazz , new Callable < List < ReflectedInfo > > ( ) { /** * This method is called if the value is not found in the cache. This * is where the real reflection work is done. */ public List < ReflectedInfo > call ( ) throws Exception { List < ReflectedInfo > exposed = new ArrayList < ReflectedInfo > ( ) ; for ( Method m : clazz . getMethods ( ) ) { if ( isIgnored ( m ) ) { continue ; } boolean methodIsSirenProperty = m . getAnnotation ( Siren4JProperty . class ) != null ; String methodAnnotationName = extractEffectiveName ( m , null ) ; if ( ReflectionUtils . isGetter ( m ) ) { Field f = getGetterField ( m ) ; if ( f != null && isIgnored ( f ) ) { continue ; } if ( f != null ) { String fieldAnnotationName = extractEffectiveName ( f , null ) ; String effectiveName = ( String ) findFirstNonNull ( Arrays . asList ( fieldAnnotationName , methodAnnotationName , f . getName ( ) ) . iterator ( ) ) ; exposed . add ( new ReflectedInfo ( f , m , ReflectionUtils . getSetter ( clazz , f ) , effectiveName ) ) ; } else if ( methodIsSirenProperty ) { // looks like we have getter not backed by field exposed . add ( ReflectedInfoBuilder . aReflectedInfo ( ) . withGetter ( m ) . withEffectiveName ( extractEffectiveName ( m , stripGetterPrefix ( m . getName ( ) ) ) ) . build ( ) ) ; } } else if ( methodIsSirenProperty ) { exposed . add ( ReflectedInfoBuilder . aReflectedInfo ( ) . withGetter ( m ) . withEffectiveName ( extractEffectiveName ( m , m . getName ( ) ) ) . build ( ) ) ; } } return exposed ; } } ) ; } catch ( ExecutionException e ) { throw new Siren4JRuntimeException ( e ) ; } return results ; }
Retrieve all fields deemed as Exposed i . e . they are public or have a public accessor method or are marked by an annotation to be exposed .