public TypeElement getGenericType ( TypeMirror typeMirror ) { return typeMirror . accept ( new SimpleTypeVisitor6 < TypeElement , Void > ( ) { @ Override public TypeElement visitDeclared ( DeclaredType declaredType , Void v ) { TypeElement genericTypeElement = null ; TypeElement typeElement = ( TypeElement ) declaredType . asElement ( ) ; if ( parcelClass != null && typeUtils . isAssignable ( typeElement . asType ( ) , listTypeMirror ) ) { List < ? extends TypeMirror > typeArguments = declaredType . getTypeArguments ( ) ; if ( ! typeArguments . isEmpty ( ) ) { for ( TypeMirror genericType : typeArguments ) { if ( genericType instanceof WildcardType ) { WildcardType wildcardType = ( WildcardType ) genericType ; TypeMirror extendsType = wildcardType . getExtendsBound ( ) ; if ( extendsType != null ) { typeElement = elementUtils . getTypeElement ( extendsType . toString ( ) ) ; if ( typeElement . getAnnotation ( parcelClass ) != null ) { genericTypeElement = typeElement ; break ; } } } else { typeElement = elementUtils . getTypeElement ( genericType . toString ( ) ) ; if ( typeElement . getAnnotation ( parcelClass ) != null ) { genericTypeElement = typeElement ; break ; } } } } } return genericTypeElement ; } } , null ) ; }
Return the generic type if any