/**
* Return the generic type if any
*/
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);
}
BindingManager.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:remoter
作者:
评论列表
文章目录