private PackageElement getPackageElement(TypeElement subscriberClass) { Element candidate = subscriberClass.getEnclosingElement(); while (!(candidate instanceof PackageElement)) { candidate = candidate.getEnclosingElement(); } return (PackageElement) candidate; }
boolean isExtension(TypeElement element) { return element.getAnnotation(GlideExtension.class) != null; }
public boolean requiredAuthentication(ExecutableElement executableElement) { RequiresAuthentication basicAuthAnnotation = executableElement.getAnnotation(RequiresAuthentication.class); if (basicAuthAnnotation == null) { basicAuthAnnotation = executableElement.getEnclosingElement().getAnnotation(RequiresAuthentication.class); } return basicAuthAnnotation != null; }
private boolean methodIsAvailableIn(TypeElement element, String methodName) { for (Element method : ElementFilter.methodsIn(element.getEnclosedElements())) { if (method.getSimpleName().contentEquals(methodName)) { return true; } } return false; }
private static String getSmartPrimitiveParameterName(VariableElement parameter) { for (AnnotationMirror annotation : parameter.getAnnotationMirrors()) { String annotationName = annotation.getAnnotationType().toString().toUpperCase(); if (annotationName.endsWith("RES")) { // Catch annotations like StringRes return "id"; } else if (annotationName.endsWith("RANGE")) { // Catch annotations like IntRange return "value"; } } return parameter.getSimpleName().toString(); }
protected boolean extendsType(Element element, String typeQualifiedName) { TypeMirror elementType = element.asType(); TypeElement typeElement = annotationHelper.typeElementFromQualifiedName(typeQualifiedName); if (typeElement != null) { TypeMirror expectedType = typeElement.asType(); return annotationHelper.isSubtype(elementType, expectedType); } return false; }
public boolean multipartHeaderRequired(ExecutableElement executableElement) { for (VariableElement parameter : executableElement.getParameters()) { if (parameter.getAnnotation(Part.class) != null) { return true; } } return false; }
public boolean hasOneOfClassAnnotations(Element element, List<Class<? extends Annotation>> validAnnotations) { for (Class<? extends Annotation> validAnnotation : validAnnotations) { if (element.getAnnotation(validAnnotation) != null) { return true; } } return false; } }
public boolean isInterface(TypeElement element) { return element.getKind().isInterface(); }
private static boolean isListenerRequired(ExecutableElement element) { return element.getAnnotation(Optional.class) == null; }
static boolean isStatic(Element element) { for (Modifier modifier : element.getModifiers()) { if (modifier.equals(Modifier.STATIC)) { return true; } } return false; }
private boolean isAnnotatedWithIndexed(Element type) { for (AnnotationMirror annotation : type.getAnnotationMirrors()) { if (isIndexedAnnotation(annotation)) { return true; } } return false; }
private boolean isInnerClass(Element element) { TypeElement typeElement = (TypeElement) element; return typeElement.getNestingKind().isNested(); } }
private String getQualifiedName(Element element) { if (element instanceof QualifiedNameable) { return ((QualifiedNameable) element).getQualifiedName().toString(); } return element.toString(); }
public String acceptedHeaders(ExecutableElement executableElement) { Accept acceptAnnotation = executableElement.getAnnotation(Accept.class); if (acceptAnnotation == null) { acceptAnnotation = executableElement.getEnclosingElement().getAnnotation(Accept.class); } if (acceptAnnotation != null) { return acceptAnnotation.value(); } else { return null; } }
public int numberOfElementParameterHasAnnotation(ExecutableElement element, Class<? extends Annotation> annotation) { int count = 0; for (VariableElement parameter : element.getParameters()) { if (parameter.getAnnotation(annotation) != null) { count++; } } return count; }
private static boolean memoizeStaticMethodFromAnnotation(ExecutableElement element) { GlideOption glideOption = element.getAnnotation(GlideOption.class); return glideOption != null && glideOption.memoizeStaticMethod(); }
public String[] requiredUrlCookies(ExecutableElement executableElement) { RequiresCookieInUrl cookieAnnotation = executableElement.getAnnotation(RequiresCookieInUrl.class); if (cookieAnnotation == null) { cookieAnnotation = executableElement.getEnclosingElement().getAnnotation(RequiresCookieInUrl.class); } if (cookieAnnotation != null) { return cookieAnnotation.value(); } else { return null; } }
int getOverrideType(ExecutableElement element) { GlideOption glideOption = element.getAnnotation(GlideOption.class); return glideOption.override(); }
private static boolean skipStaticMethod(ExecutableElement element) { GlideOption glideOption = element.getAnnotation(GlideOption.class); return glideOption != null && glideOption.skipStaticMethod(); }