private static String handleField ( CtField field , CtClass clazz ) throws NotFoundException , CannotCompileException { StringBuilder builder = new StringBuilder ( ) ; CtClass fieldType = field . getType ( ) ; String property = field . getName ( ) ; if ( fieldType . equals ( cp . get ( File . class . getName ( ) ) ) ) { return handleFileField ( property , clazz ) ; } CtMethod getter = getFieldGetter ( field , clazz ) ; if ( getter == null ) { LOGGER . warn ( String . format ( "Ignoring property '%s' since there is no getter for it defined" , property ) ) ; } else if ( fieldType . isPrimitive ( ) ) { builder . append ( createTrace ( String . format ( "Handle primitive type property '%s'" , property ) ) ) ; CtPrimitiveType primitiveType = ( CtPrimitiveType ) fieldType ; String wrapperName = primitiveType . getWrapperName ( ) ; builder . append ( String . format ( "elements.add(new OpenEngSBModelEntry(\"%s\", %s.valueOf(%s()), %s.class));\n" , property , wrapperName , getter . getName ( ) , wrapperName ) ) ; } else { builder . append ( createTrace ( String . format ( "Handle property '%s'" , property ) ) ) . append ( String . format ( "elements.add(new OpenEngSBModelEntry(\"%s\", %s(), %s.class));\n" , property , getter . getName ( ) , fieldType . getName ( ) ) ) ; } return builder . toString ( ) ; }
Analyzes the given field and add logic based on the type of the field .