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