use of com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteCreatorMeta in project storio by pushtorefresh.
the class StorIOSQLiteProcessor method processAnnotatedExecutables.
/**
* Processes factory methods or constructors annotated with {@link StorIOSQLiteCreator}.
*
* @param roundEnvironment current processing environment
* @param annotatedClasses map of classes annotated with {@link StorIOSQLiteType}
*/
@Override
protected void processAnnotatedExecutables(@NotNull RoundEnvironment roundEnvironment, @NotNull Map<TypeElement, StorIOSQLiteTypeMeta> annotatedClasses) {
final Set<? extends Element> elementsAnnotatedWithStorIOSQLiteCreator = roundEnvironment.getElementsAnnotatedWith(StorIOSQLiteCreator.class);
for (final Element annotatedElement : elementsAnnotatedWithStorIOSQLiteCreator) {
final ExecutableElement annotatedExecutableElement = (ExecutableElement) annotatedElement;
validateAnnotatedExecutable(annotatedExecutableElement);
final StorIOSQLiteCreatorMeta storIOSQLiteCreatorMeta = new StorIOSQLiteCreatorMeta(annotatedExecutableElement.getEnclosingElement(), annotatedExecutableElement, annotatedExecutableElement.getAnnotation(StorIOSQLiteCreator.class));
final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = annotatedClasses.get(storIOSQLiteCreatorMeta.enclosingElement);
// If class already contains another creator -> throw exception.
if (storIOSQLiteTypeMeta.creator == null) {
storIOSQLiteTypeMeta.creator = annotatedExecutableElement;
} else {
throw new ProcessingException(annotatedExecutableElement, "Only one creator method or constructor is allowed: " + annotatedExecutableElement.getEnclosingElement().getSimpleName());
}
}
}
Aggregations