public static TypeName extractReturnType ( final SQLiteModelMethod method ) { SQLiteEntity daoEntity = method . getParent ( ) . getEntity ( ) ; // if true, field must be associate to ben attributes TypeName returnTypeName = method . getReturnClass ( ) ; TypeName result = null ; if ( TypeUtility . isTypeIncludedIn ( returnTypeName , Void . class , Void . TYPE ) ) { // return VOID (in the parameters must be a listener) // case OnReadBeanListener Pair < String , TypeName > foundElement = SqlBuilderHelper . searchInEachParameter ( method , new SqlBuilderHelper . OnParameterListener ( ) { @ Override public boolean onParameter ( Pair < String , TypeName > item ) { return ( item . value1 instanceof ParameterizedTypeName && TypeUtility . isEquals ( ( ( ParameterizedTypeName ) item . value1 ) . rawType , OnReadBeanListener . class . getName ( ) ) ) ; } } ) ; if ( foundElement != null ) { result = ( ( ParameterizedTypeName ) foundElement . value1 ) . typeArguments . get ( 0 ) ; } } else if ( TypeUtility . isTypeIncludedIn ( returnTypeName , Cursor . class ) ) { // return Cursor (no listener) result = null ; } else if ( returnTypeName instanceof ParameterizedTypeName ) { ParameterizedTypeName returnParameterizedTypeName = ( ParameterizedTypeName ) returnTypeName ; ClassName returnParameterizedClassName = returnParameterizedTypeName . rawType ; // return List (no listener) AssertKripton . assertTrueOrInvalidMethodSignException ( returnParameterizedTypeName . typeArguments . size ( ) == 1 , method , "return type %s is not supported" , returnTypeName ) ; TypeName elementName = returnParameterizedTypeName . typeArguments . get ( 0 ) ; Class < ? > wrapperClazz = null ; try { wrapperClazz = Class . forName ( returnParameterizedClassName . toString ( ) ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; throw ( new KriptonClassNotFoundException ( e ) ) ; } if ( PagedResultImpl . class . isAssignableFrom ( wrapperClazz ) || Collection . class . isAssignableFrom ( wrapperClazz ) ) { if ( SQLTransformer . isSupportedJDKType ( elementName ) || TypeUtility . isByteArray ( elementName ) ) { // scalar list result = null ; } else { result = elementName ; } } else { result = null ; } } else if ( TypeUtility . isEquals ( returnTypeName , daoEntity ) ) { // return one element (no listener) result = null ; } else if ( SQLTransformer . isSupportedJDKType ( returnTypeName ) || TypeUtility . isByteArray ( returnTypeName ) ) { // return single value string, int, long, short, double, float, // String (no listener) result = null ; } else { result = returnTypeName ; } if ( result == null || TypeUtility . isEquals ( result , daoEntity ) ) { return null ; } else { return result ; } }
Detect result type .