protected FieldInformationImplementation(@Nonnull Element element, @Nonnull TypeMirror type, @Nonnull DeclaredType containingType) { super(element, type, containingType); this.defaultValue = ProcessingUtility.getString(ProcessingUtility.getAnnotationValue(element, Default.class)); }
/** * Returns the boxed type of the given type mirror or its component type in case of arrays. */ @Pure public static @Nonnull TypeMirror getBoxedType(@Nonnull TypeMirror typeMirror) { if (isPrimitive(typeMirror)) { return getType(StaticProcessingEnvironment.getTypeUtils().boxedClass((PrimitiveType) typeMirror)); } else { return typeMirror; } }
/** * Returns whether the type of the given element corresponds to the given type. */ @Pure public static boolean correspond(@Nonnull Element element, @Nonnull Class<?> type) { return correspond(getType(element), type); }
@Pure @Override public @Nonnull String visitType(@Nonnull TypeMirror type, @NonCaptured @Modified @Nullable TypeImporter typeImporter) { final @Nonnull String qualifiedTypeName = ProcessingUtility.getQualifiedName(type); return (typeImporter != null ? typeImporter.importIfPossible(qualifiedTypeName) : qualifiedTypeName) + ".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); }
/** * Returns whether the given declared type is a raw subtype of the given desired type. */ @Pure public static boolean isRawSubtype(@Nonnull TypeMirror declaredType, @Nonnull Class<?> desiredType) { final @Nullable TypeMirror typeMirror = getErasedTypeMirror(desiredType); return typeMirror != null ? StaticProcessingEnvironment.getTypeUtils().isSubtype(declaredType, typeMirror) : false; }
/** * Returns whether the type of the given element is a raw subtype of the given type. */ @Pure public static boolean isRawSubtype(@Nonnull Element element, @Nonnull Class<?> type) { return isRawSubtype(getType(element), type); }
/** * Returns the given class object as an erased type mirror. */ @Pure @LogsErrorWhenReturningNull public static @Nullable TypeMirror getErasedTypeMirror(@Nonnull Class<?> type) { final @Nullable TypeMirror typeMirror = getTypeMirror(type); return typeMirror != null ? StaticProcessingEnvironment.getTypeUtils().erasure(typeMirror) : null; }
private boolean shouldGenerateInitializeCall() { return ProcessingUtility.isRawlyAssignable(typeInformation.getElement(), RootClassWithException.class); }
/** * Returns the directly declared and inherited fields of the given type element. */ @Pure public static @Nonnull FiniteIterable<@Nonnull VariableElement> getAllFields(@Nonnull TypeElement typeElement) { return filter(getAllMembers(typeElement), ElementKind.FIELD, VariableElement.class); }
/** * Returns the simple name of the given annotation mirror with a leading at symbol. */ @Pure public static @Nonnull String getSimpleNameWithLeadingAt(@Nonnull AnnotationMirror annotationMirror) { return "@" + getSimpleName(annotationMirror); }
@Pure // TODO: Why is this method not in the interface? public boolean isIterable() { return ProcessingUtility.isRawSubtype(getType(), Iterable.class); }
/** * Returns the directly declared fields of the given type element. */ @Pure public static @Nonnull FiniteIterable<@Nonnull VariableElement> getFields(@Nonnull TypeElement typeElement) { return filter(getMembers(typeElement), ElementKind.FIELD, VariableElement.class); }
/** * Returns whether the given element has an annotation of the given type. */ @Pure public static boolean hasAnnotation(@Nonnull Element element, @Nonnull Class<? extends Annotation> annotationType) { return getAnnotationMirror(element, annotationType) != null; }
/** * Returns the qualified name of the given type mirror without generic parameters. */ @Pure public static @Nonnull String getQualifiedName(@Nonnull TypeMirror typeMirror) { return QUALIFIED_NAME_TYPE_VISITOR.visit(typeMirror); }
/** * Returns the simple name of the given type mirror without generic parameters. */ @Pure public static @Nonnull String getSimpleName(@Nonnull TypeMirror typeMirror) { return SIMPLE_NAME_TYPE_VISITOR.visit(typeMirror); }
/** * Returns whether the {@link #getElement() element} is declared in the Java Runtime Environment (JRE). */ @Pure public default boolean isDeclaredInRuntimeEnvironment() { return ProcessingUtility.isDeclaredInRuntimeEnvironment(getElement()); }
/** * Returns whether the given declared type is rawly assignable to the given desired type. */ @Pure public static boolean isRawlyAssignable(@Nonnull TypeMirror declaredType, @Nonnull Class<?> desiredType) { final @Nullable TypeMirror typeMirror = getErasedTypeMirror(desiredType); return typeMirror != null ? StaticProcessingEnvironment.getTypeUtils().isAssignable(declaredType, typeMirror) : false; }
/** * Returns the directly declared and inherited methods of the given type element. */ @Pure public static @Nonnull FiniteIterable<@Nonnull ExecutableElement> getAllMethods(@Nonnull TypeElement typeElement) { return filter(getAllMembers(typeElement), ElementKind.METHOD, ExecutableElement.class); }
/** * Returns the directly declared constructors of the given type element. */ @Pure public static @Nonnull FiniteIterable<@Nonnull ExecutableElement> getConstructors(@Nonnull TypeElement typeElement) { return filter(getMembers(typeElement), ElementKind.CONSTRUCTOR, ExecutableElement.class); }