@Pure public boolean isAssignable(@Nonnull Class<?> clazz) { return ProcessingUtility.isRawlyAssignable(typeMirror, clazz); }
private boolean shouldGenerateInitializeCall() { return ProcessingUtility.isRawlyAssignable(typeInformation.getElement(), RootClassWithException.class); }
/** * Returns whether the given method is a (potentially static) getter. */ @Pure public static boolean isGetter(@Nonnull ExecutableElement method) { final @Nonnull String name = method.getSimpleName().toString(); return method.getKind() == ElementKind.METHOD && method.getTypeParameters().isEmpty() && method.getThrownTypes().isEmpty() && method.getParameters().isEmpty() && method.getReturnType().getKind() != TypeKind.VOID && (name.startsWith("get") || (name.startsWith("is") || name.startsWith("has") || name.startsWith("can")) && isRawlyAssignable(method.getReturnType(), boolean.class)); }
/** * Returns whether the given element is rawly assignable to the given type. */ @Pure public static boolean isRawlyAssignable(@Nonnull Element element, @Nonnull Class<?> type) { return isRawlyAssignable(getType(element), type); }
@Pure @Override public void checkUsage(@Nonnull Element element, @Nonnull AnnotationMirror annotationMirror, @NonCaptured @Modified @Nonnull ErrorLogger errorLogger) { final @Nonnull TypeMirror declaredType = ProcessingUtility.getType(element); final @Nullable Class<?> desiredType = ProcessingUtility.getClass(ProcessingUtility.getAnnotationValue(annotationMirror)); if (desiredType != null && ProcessingUtility.isRawlyAssignable(declaredType, desiredType)) { errorLogger.log("The value of type $ is rawly assignable to $:", SourcePosition.of(element), ProcessingUtility.getSimpleName(declaredType), desiredType.getSimpleName()); } }
@Pure @Override public void checkUsage(@Nonnull Element element, @Nonnull AnnotationMirror annotationMirror, @NonCaptured @Modified @Nonnull ErrorLogger errorLogger) { final @Nonnull TypeMirror declaredType = ProcessingUtility.getType(element); final @Nullable Class<?> desiredType = ProcessingUtility.getClass(ProcessingUtility.getAnnotationValue(annotationMirror)); if (desiredType != null && !ProcessingUtility.isRawlyAssignable(declaredType, desiredType)) { errorLogger.log("The value of type $ is not rawly assignable to $:", SourcePosition.of(element), ProcessingUtility.getSimpleName(declaredType), desiredType.getSimpleName()); } }