private static boolean isListenerRequired(ExecutableElement element) { return element.getAnnotation(Optional.class) == null; }
private static boolean canCreateDiffModels( ExecutableElement method, List<Class<? extends Annotation>> delegateMethodAnnotationsThatSkipDiffModels) { for (Class<? extends Annotation> delegate : delegateMethodAnnotationsThatSkipDiffModels) { if (method.getAnnotation(delegate) != null) { return false; } } return true; }
public boolean requiredAuthentication(ExecutableElement executableElement) { RequiresAuthentication basicAuthAnnotation = executableElement.getAnnotation(RequiresAuthentication.class); if (basicAuthAnnotation == null) { basicAuthAnnotation = executableElement.getEnclosingElement().getAnnotation(RequiresAuthentication.class); } return basicAuthAnnotation != null; }
private static boolean skipStaticMethod(ExecutableElement element) { GlideOption glideOption = element.getAnnotation(GlideOption.class); return glideOption != null && glideOption.skipStaticMethod(); }
private static boolean memoizeStaticMethodFromAnnotation(ExecutableElement element) { GlideOption glideOption = element.getAnnotation(GlideOption.class); return glideOption != null && glideOption.memoizeStaticMethod(); }
int getOverrideType(ExecutableElement element) { GlideOption glideOption = element.getAnnotation(GlideOption.class); return glideOption.override(); }
public String[] requiredHeaders(ExecutableElement executableElement) { RequiresHeader requiresHeaderAnnotation = executableElement.getAnnotation(RequiresHeader.class); if (requiresHeaderAnnotation == null) { requiresHeaderAnnotation = executableElement.getEnclosingElement().getAnnotation(RequiresHeader.class); } if (requiresHeaderAnnotation != null) { return requiresHeaderAnnotation.value(); } else { return null; } }
private List<ExecutableElement> methodsAnnotatedWith( Element returnType, Class<? extends Annotation> annotationType ) { return ElementFilter.methodsIn( returnType.getEnclosedElements() ).stream() .filter( m -> m.getAnnotation( annotationType ) != null ).collect( Collectors.toList() ); }
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; } }
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; } }
private List<MethodAndStaticVar> generateStaticMethodOverridesForRequestOptions() { List<ExecutableElement> staticMethodsThatReturnRequestOptions = processorUtil.findStaticMethodsReturning(requestOptionsType, requestOptionsType); List<MethodAndStaticVar> staticMethods = new ArrayList<>(); for (ExecutableElement element : staticMethodsThatReturnRequestOptions) { if (element.getAnnotation(Deprecated.class) != null) { continue; } staticMethods.add(generateStaticMethodEquivalentForRequestOptionsStaticMethod(element)); } return staticMethods; }
@Nullable private static String getStaticMethodName(ExecutableElement element) { GlideOption glideOption = element.getAnnotation(GlideOption.class); String result = glideOption != null ? glideOption.staticMethodName() : null; return Strings.emptyToNull(result); }
private Stream<CompilationMessage> validatePerformsWriteUsage( ExecutableElement executableElement ) { if ( executableElement.getAnnotation( PerformsWrites.class ) != null ) { return performsWriteVisitor.visit( executableElement ); } return Stream.empty(); }
protected ProviderMethodBinding(String provideKey, ExecutableElement method, boolean library) { super(provideKey, method.getAnnotation(Singleton.class) != null, className(method), method.getSimpleName().toString()); this.method = method; this.parameters = new Binding[method.getParameters().size()]; setLibrary(library); }
void validateExtension(TypeElement typeElement) { if (!typeElement.getModifiers().contains(Modifier.PUBLIC)) { throw new IllegalArgumentException( "RequestOptionsExtensions must be public, including: " + getName(typeElement)); } for (Element element : typeElement.getEnclosedElements()) { if (element.getKind() == ElementKind.CONSTRUCTOR) { validateExtensionConstructor(element); } else if (element.getKind() == ElementKind.METHOD) { ExecutableElement executableElement = (ExecutableElement) element; if (executableElement.getAnnotation(GlideOption.class) != null) { validateGlideOption(executableElement); } else if (executableElement.getAnnotation(GlideType.class) != null) { validateGlideType(executableElement); } } } }
private Map<String, String> getHeadersFromAnnotations(ExecutableElement executableElement) { Headers headers = executableElement.getAnnotation(Headers.class); Map<String, String> headerMap = new HashMap<>(); if (headers != null) { Header[] headerList = headers.value(); for (Header header : headerList) { headerMap.put(header.name(), header.value()); } } Header header = executableElement.getAnnotation(Header.class); if (header != null) { headerMap.put(header.name(), header.value()); } return headerMap; }
private <T extends Annotation> void checkDefaultAnnotation(ExecutableElement method, Class<T> annotationClass, String expectedReturnType, DefaultAnnotationCondition condition, ElementValidation valid) { T defaultAnnotation = method.getAnnotation(annotationClass); if (defaultAnnotation != null) { if (!condition.correctReturnType(method.getReturnType())) { valid.addError(TargetAnnotationHelper.annotationName(annotationClass) + " can only be used on a method that returns a " + expectedReturnType); } } }
String eventClass = getClassString(paramElement, myPackage) + ".class"; Subscribe subscribe = method.getAnnotation(Subscribe.class); List<String> parts = new ArrayList<>(); parts.add(callPrefix + "(\"" + methodName + "\",");