protected String getAccessByField ( String target , Field field , Class < ? > cls ) { if ( field . getModifiers ( ) == Modifier . PUBLIC ) { return target + ClassHelper . PACKAGE_SEPARATOR + field . getName ( ) ; } // check if has getter method String getter ; if ( "boolean" . equalsIgnoreCase ( field . getType ( ) . getCanonicalName ( ) ) ) { getter = "is" + CodedConstant . capitalize ( field . getName ( ) ) ; } else { getter = "get" + CodedConstant . capitalize ( field . getName ( ) ) ; } // check method exist try { cls . getMethod ( getter , new Class < ? > [ 0 ] ) ; return target + ClassHelper . PACKAGE_SEPARATOR + getter + "()" ; } catch ( Exception e ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( e . getMessage ( ) , e ) ; } } String type = field . getType ( ) . getCanonicalName ( ) ; if ( "[B" . equals ( type ) || "[Ljava.lang.Byte;" . equals ( type ) || "java.lang.Byte[]" . equals ( type ) ) { type = "byte[]" ; } // use reflection to get value String code = "(" + FieldUtils . toObjectType ( type ) + ") " ; code += "FieldUtils.getField(" + target + ", \"" + field . getName ( ) + "\")" ; return code ; }
get field access code .