public static ResultDescriptor analyzeReturnType ( final DescriptorContext context , final Class < ? extends Collection > returnCollectionType ) { final Method method = context . method ; final MethodGenericsContext generics = context . generics . method ( method ) ; final Class < ? > returnClass = generics . resolveReturnClass ( ) ; final ResultDescriptor descriptor = new ResultDescriptor ( ) ; descriptor . expectType = resolveExpectedType ( returnClass , returnCollectionType ) ; final ResultType type ; final Class < ? > entityClass ; if ( isCollection ( returnClass ) ) { type = COLLECTION ; entityClass = resolveGenericType ( method , generics ) ; } else if ( returnClass . isArray ( ) ) { type = ARRAY ; entityClass = returnClass . getComponentType ( ) ; } else if ( VOID_TYPES . contains ( returnClass ) ) { type = VOID ; entityClass = Void . class ; } else { type = PLAIN ; // support for guava and jdk8 optionals entityClass = Optionals . isOptional ( returnClass ) ? resolveGenericType ( method , generics ) : returnClass ; } descriptor . returnType = type ; descriptor . entityType = entityClass ; return descriptor ; }
Analyze return type .