public static < T > boolean hasDeclaredGetterAndSetter ( final Field field , Class < T > entityClazz ) { boolean hasDeclaredAccessorsMutators = true ; Method getter = retrieveGetterFrom ( entityClazz , field . getName ( ) ) ; Method setter = retrieveSetterFrom ( entityClazz , field . getName ( ) ) ; if ( getter == null || setter == null ) { hasDeclaredAccessorsMutators = false ; } return hasDeclaredAccessorsMutators ; }
This method checks if the declared Field is accessible through getters and setters methods Fields which have only setters OR getters and NOT both are discarded from serialization process