List of usage examples for javax.lang.model.type ArrayType getComponentType
TypeMirror getComponentType();
From source file:com.googlecode.androidannotations.helper.ValidatorHelper.java
public void canBeSavedAsInstanceState(Element element, IsValid isValid) { String typeString = element.asType().toString(); if (!isKnowInstanceStateType(typeString)) { if (element.asType() instanceof DeclaredType) { DeclaredType declaredType = (DeclaredType) element.asType(); typeString = declaredType.asElement().toString(); } else if (element.asType() instanceof ArrayType) { ArrayType arrayType = (ArrayType) element.asType(); TypeMirror componentType = arrayType.getComponentType(); if (componentType instanceof DeclaredType) { DeclaredType declaredType = (DeclaredType) componentType; typeString = declaredType.asElement().toString(); } else { typeString = componentType.toString(); }/*from www . j a v a 2 s .c o m*/ } else { typeString = element.asType().toString(); } TypeElement elementType = annotationHelper.typeElementFromQualifiedName(typeString); if (elementType == null) { elementType = getArrayEnclosingType(typeString); if (elementType == null) { annotationHelper.printAnnotationError(element, "Unrecognized type. Please let your attribute be primitive or implement Serializable or Parcelable"); isValid.invalidate(); } } if (elementType != null) { TypeElement parcelableType = annotationHelper.typeElementFromQualifiedName("android.os.Parcelable"); TypeElement serializableType = annotationHelper .typeElementFromQualifiedName("java.io.Serializable"); if (!annotationHelper.isSubtype(elementType, parcelableType) && !annotationHelper.isSubtype(elementType, serializableType)) { annotationHelper.printAnnotationError(element, "Unrecognized type. Please let your attribute be primitive or implement Serializable or Parcelable"); isValid.invalidate(); } } } }
From source file:org.androidannotations.helper.ValidatorHelper.java
public void canBePutInABundle(Element element, IsValid isValid) { String typeString = element.asType().toString(); if (!isKnownBundleCompatibleType(typeString)) { if (element.asType() instanceof DeclaredType) { DeclaredType declaredType = (DeclaredType) element.asType(); typeString = declaredType.asElement().toString(); } else if (element.asType() instanceof ArrayType) { ArrayType arrayType = (ArrayType) element.asType(); TypeMirror componentType = arrayType.getComponentType(); if (componentType instanceof DeclaredType) { DeclaredType declaredType = (DeclaredType) componentType; typeString = declaredType.asElement().toString(); } else { typeString = componentType.toString(); }//w w w . ja va 2s.c o m } else { typeString = element.asType().toString(); } TypeElement elementType = annotationHelper.typeElementFromQualifiedName(typeString); if (elementType == null) { elementType = getArrayEnclosingType(typeString); if (elementType == null) { annotationHelper.printAnnotationError(element, "Unrecognized type. Please let your attribute be primitive or implement Serializable or Parcelable"); isValid.invalidate(); } } if (elementType != null) { TypeElement parcelableType = annotationHelper .typeElementFromQualifiedName(CanonicalNameConstants.PARCELABLE); TypeElement serializableType = annotationHelper .typeElementFromQualifiedName("java.io.Serializable"); if (!annotationHelper.isSubtype(elementType, parcelableType) && !annotationHelper.isSubtype(elementType, serializableType)) { annotationHelper.printAnnotationError(element, "Unrecognized type. Please let your attribute be primitive or implement Serializable or Parcelable"); isValid.invalidate(); } } } }