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; } }
List<ExecutableElement> findAnnotatedElementsInClasses( Set<String> classNames, Class<? extends Annotation> annotationClass) { List<ExecutableElement> result = new ArrayList<>(); for (String glideExtensionClassName : classNames) { TypeElement glideExtension = processingEnv.getElementUtils() .getTypeElement(glideExtensionClassName); for (Element element : glideExtension.getEnclosedElements()) { if (element.getAnnotation(annotationClass) != null) { result.add((ExecutableElement) element); } } } return result; }
@Override protected String getUrlSuffix(Element element) { Options annotation = element.getAnnotation(Options.class); return annotation.value(); }
@Override protected String getUrlSuffix(Element element) { Put annotation = element.getAnnotation(Put.class); return annotation.value(); } }
@Override protected String getUrlSuffix(Element element) { Get annotation = element.getAnnotation(Get.class); return annotation.value(); } }
public boolean requiredAuthentication(ExecutableElement executableElement) { RequiresAuthentication basicAuthAnnotation = executableElement.getAnnotation(RequiresAuthentication.class); if (basicAuthAnnotation == null) { basicAuthAnnotation = executableElement.getEnclosingElement().getAnnotation(RequiresAuthentication.class); } return basicAuthAnnotation != null; }
@Override protected String getUrlSuffix(Element element) { Post annotation = element.getAnnotation(Post.class); return annotation.value(); } }
private String extractTag(Element element) { WakeLock annotation = element.getAnnotation(WakeLock.class); String tag = annotation.tag(); if (WakeLock.DEFAULT_TAG.equals(tag)) { tag = element.getEnclosingElement().getSimpleName().toString() + "." + element.getSimpleName().toString(); } return tag; } }
private String extractTag(Element element) { Trace annotation = element.getAnnotation(Trace.class); String tag = annotation.tag(); if (Trace.DEFAULT_TAG.equals(tag)) { tag = element.getEnclosingElement().getSimpleName().toString(); } return trimLogTag(tag); } }
public void hasValidLogLevel(Element element, ElementValidation valid) { Trace annotation = element.getAnnotation(Trace.class); Integer level = annotation.level(); if (!VALID_LOG_LEVELS.contains(level)) { valid.addError("Unrecognized log level."); } }
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 String[] requiredCookies(ExecutableElement executableElement) { RequiresCookie cookieAnnotation = executableElement.getAnnotation(RequiresCookie.class); if (cookieAnnotation == null) { cookieAnnotation = executableElement.getEnclosingElement().getAnnotation(RequiresCookie.class); } if (cookieAnnotation != null) { return cookieAnnotation.value(); } else { return null; } }
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; } }
public String[] settingCookies(ExecutableElement executableElement) { SetsCookie cookieAnnotation = executableElement.getAnnotation(SetsCookie.class); if (cookieAnnotation == null) { cookieAnnotation = executableElement.getEnclosingElement().getAnnotation(SetsCookie.class); } if (cookieAnnotation != null) { return cookieAnnotation.value(); } else { return null; } }
@Override protected IJExpression getFragmentId(Element element, String fieldName) { FragmentByTag annotation = element.getAnnotation(FragmentByTag.class); String tagValue = annotation.value(); if (tagValue.equals("")) { tagValue = fieldName; } return lit(tagValue); } }
public void elementHasAnnotation(Class<? extends Annotation> annotation, Element element, ElementValidation valid, String error) { if (!elementHasAnnotation(annotation, element)) { if (element.getAnnotation(annotation) == null) { valid.addError("%s " + error + " @" + annotation.getName()); } } }
@SuppressWarnings("unchecked") private FoundIndexedClassNames getIndexedClassNames(PackageElement glideGenPackage) { Set<String> glideModules = new HashSet<>(); Set<String> extensions = new HashSet<>(); List<? extends Element> glideGeneratedElements = glideGenPackage.getEnclosedElements(); for (Element indexer : glideGeneratedElements) { Index annotation = indexer.getAnnotation(Index.class); // If the annotation is null, it means we've come across another class in the same package // that we can safely ignore. if (annotation != null) { Collections.addAll(glideModules, annotation.modules()); Collections.addAll(extensions, annotation.extensions()); } } processorUtil.debugLog("Found GlideModules: " + glideModules); return new FoundIndexedClassNames(glideModules, extensions); }
public void copyNonAAAnnotations(IJAnnotatable annotatable, List<? extends AnnotationMirror> annotationMirrors) { for (AnnotationMirror annotationMirror : annotationMirrors) { if (annotationMirror.getAnnotationType().asElement().getAnnotation(Inherited.class) == null) { AbstractJClass annotationClass = typeMirrorToJClass(annotationMirror.getAnnotationType()); if (!environment.isAndroidAnnotation(annotationClass.fullName()) && !IGNORED_ANNOTATIONS.contains(annotationClass.fullName())) { copyAnnotation(annotatable, annotationMirror); } } } }
public JInvocation newBeanOrEBean(DeclaredType beanType, JVar contextVar) { if (beanType.asElement().getAnnotation(EBean.class) != null) { String typeQualifiedName = beanType.toString(); AbstractJClass injectedClass = environment.getJClass(typeQualifiedName + classSuffix()); return injectedClass.staticInvoke(EBeanHolder.GET_INSTANCE_METHOD_NAME).arg(contextVar); } else { return _new(environment.getJClass(beanType.toString())); } }
@Override public void process(Element element, EBeanHolder holder) { EBean eBeanAnnotation = element.getAnnotation(EBean.class); EBean.Scope eBeanScope = eBeanAnnotation.scope(); boolean hasSingletonScope = eBeanScope == EBean.Scope.Singleton; holder.createFactoryMethod(hasSingletonScope); if (!hasSingletonScope) { holder.invokeInitInConstructor(); holder.createRebindMethod(); } } }