Example usage for javax.annotation.processing RoundEnvironment getElementsAnnotatedWith

List of usage examples for javax.annotation.processing RoundEnvironment getElementsAnnotatedWith

Introduction

In this page you can find the example usage for javax.annotation.processing RoundEnvironment getElementsAnnotatedWith.

Prototype

Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a);

Source Link

Document

Returns the elements annotated with the given annotation type.

Usage

From source file:org.versly.rest.wsdoc.AnnotationProcessor.java

private void processElements(RoundEnvironment roundEnvironment, Collection<String> processedPackageNames,
        RestImplementationSupport implementationSupport) {

    for (Element e : roundEnvironment
            .getElementsAnnotatedWith(implementationSupport.getMappingAnnotationType())) {

        if (e instanceof ExecutableElement) {
            addPackageName(processedPackageNames, e);
            processRequestMappingMethod((ExecutableElement) e, implementationSupport);
        }//from  w w  w . java 2s  .  com
    }
}

From source file:therian.buildweaver.StandardOperatorsProcessor.java

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    try {//w w  w .j  a v  a  2 s.co m
        final FileObject resource = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT,
                StringUtils.substringBeforeLast(TARGET_CLASSNAME, ".").replace('.', '/'),
                StringUtils.substringAfterLast(TARGET_CLASSNAME, ".") + ".class");

        if (resource.getLastModified() > 0L) {
            processingEnv.getMessager().printMessage(Kind.NOTE,
                    String.format("%s already generated", TARGET_CLASSNAME));
            return false;
        }
    } catch (IOException e1) {
        // expected, swallow
    }
    try {
        ClassUtils.getClass(TARGET_CLASSNAME);
        processingEnv.getMessager().printMessage(Kind.ERROR,
                String.format("%s exists on classpath", TARGET_CLASSNAME));
        return false;
    } catch (ClassNotFoundException e) {
        // expected, swallow
    }

    if (roundEnv.processingOver()) {
        write();
        return true;
    }
    for (TypeElement ann : annotations) {
        final Set<? extends Element> standardOperatorElements = roundEnv.getElementsAnnotatedWith(ann);
        originatingElements.addAll(standardOperatorElements);

        for (Element element : standardOperatorElements) {
            Validate.validState(isValidStandardOperator(element), "%s is not a valid @StandardOperator",
                    appendTo(new StringBuilder(), element).toString());

            if (element.getKind() == ElementKind.CLASS) {
                operators.add(appendTo(new StringBuilder("new "), element).append("()").toString());
            }
            if (element.getKind() == ElementKind.METHOD) {
                operators.add(appendTo(new StringBuilder(), element).append("()").toString());
            }
            if (element.getKind() == ElementKind.FIELD) {
                operators.add(appendTo(new StringBuilder(), element).toString());
            }
        }
    }
    return true;
}

From source file:co.touchlab.squeaky.processor.AnnotationProcessor.java

private boolean safeProcess(RoundEnvironment roundEnv) {
    baseClasses = new ArrayList<ClassName>();
    generatedClasses = new ArrayList<ClassName>();

    List<DatabaseTableHolder> tableHolders = new ArrayList<DatabaseTableHolder>();

    for (Element annotatedElement : roundEnv.getElementsAnnotatedWith(DatabaseTable.class)) {
        if (!annotatedElement.getKind().isClass()) {
            error(annotatedElement, "Only classes can be annotated with %s",
                    DatabaseTable.class.getSimpleName());
            return false;
        }/* ww  w  . j  a  v a  2 s. com*/
        if (processTableViewQuery(tableHolders, annotatedElement, EntityType.Table))
            return false;
    }

    for (Element annotatedElement : roundEnv.getElementsAnnotatedWith(DatabaseView.class)) {
        if (!annotatedElement.getKind().isClass()) {
            error(annotatedElement, "Only classes can be annotated with %s",
                    DatabaseView.class.getSimpleName());
            return false;
        }
        if (processTableViewQuery(tableHolders, annotatedElement, EntityType.View))
            return false;
    }

    for (Element annotatedElement : roundEnv.getElementsAnnotatedWith(DatabaseQuery.class)) {
        if (!annotatedElement.getKind().isClass()) {
            error(annotatedElement, "Only classes can be annotated with %s",
                    DatabaseQuery.class.getSimpleName());
            return false;
        }
        if (processTableViewQuery(tableHolders, annotatedElement, EntityType.Query))
            return false;
    }

    for (DatabaseTableHolder tableHolder : tableHolders) {
        JavaFile javaFile = generateClassConfigFile(tableHolders, tableHolder);

        try {
            javaFile.writeTo(filer);
        } catch (IOException e) {
            error(tableHolder.typeElement, "Code gen failed: " + e);
            return false;
        }
    }

    return false;
}

From source file:com.mastfrog.parameters.processor.Processor.java

@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment re) {

    SourceVersion sv = processingEnv.getSourceVersion();
    if (sv.ordinal() > SourceVersion.RELEASE_7.ordinal()) {
        optionalType = "java.util.Optional";
    } else {/*from www. j  av a 2  s.  c  o  m*/
        TypeElement el = processingEnv.getElementUtils().getTypeElement(optionalType);
        if (el == null) {
            optionalType = "com.mastfrog.util.Optional";
        } else {
            optionalType = "com.google.common.base.Optional";
            fromNullable = "fromNullable";
        }
    }

    Set<? extends Element> all = re.getElementsAnnotatedWith(Params.class);
    List<GeneratedParamsClass> interfaces = new LinkedList<>();
    outer: for (Element e : all) {
        TypeElement te = (TypeElement) e;
        if (te.getSimpleName().toString().endsWith("__GenPage")) {
            continue;
        }
        PackageElement pkg = findPackage(e);
        if (pkg == null) {
            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
                    "@Params may not be used in the default package", e);
            continue;
        }
        if (!isPageSubtype(te)) {
            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
                    "@Params must be used on a subclass of org.apache.wicket.Page", e);
            continue;
        }
        String className = te.getQualifiedName().toString();
        Params params = te.getAnnotation(Params.class);

        Map<String, List<String>> validators = validatorsForParam(e);
        GeneratedParamsClass inf = new GeneratedParamsClass(className, te, pkg, params, validators);

        if (!params.useRequestBody()) {
            checkConstructor(te, inf);
        }
        interfaces.add(inf);
        Set<String> names = new HashSet<>();
        for (Param param : params.value()) {
            //                if (param.required() && !param.defaultValue().isEmpty()) {
            //                    processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Don't set required to "
            //                            + "true if you are providing a default value - required makes it an error not "
            //                            + "to have a value, and if there is a default value, that error is an impossibility "
            //                            + "because it will always have a value.", e);
            //                    continue outer;
            //                }
            if (param.value().trim().isEmpty()) {
                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Empty parameter name", e);
                continue outer;
            }
            if (!isJavaIdentifier(param.value())) {
                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
                        "Not a valid Java identifier: " + param.value(), e);
                continue outer;
            }
            if (!names.add(param.value())) {
                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
                        "Duplicate parameter name '" + param.value() + "'", e);
                continue outer;
            }
            for (char c : ";,./*!@&^/\\<>?'\"[]{}-=+)(".toCharArray()) {
                if (param.value().contains("" + c)) {
                    processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
                            "Param name may not contain the character '" + c + "'", e);
                }
            }
            inf.add(param);
        }
    }
    Filer filer = processingEnv.getFiler();
    StringBuilder listBuilder = new StringBuilder();
    for (GeneratedParamsClass inf : interfaces) {
        try {
            String pth = inf.packageAsPath() + '/' + inf.className;
            pth = pth.replace('/', '.');
            JavaFileObject obj = filer.createSourceFile(pth, inf.el);
            try (OutputStream out = obj.openOutputStream()) {
                out.write(inf.toString().getBytes("UTF-8"));
            }
            listBuilder.append(inf.className).append('\n');
        } catch (Exception ex) {
            ex.printStackTrace();
            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
                    "Error processing annotation: " + ex.getMessage(), inf.el);
            Logger.getLogger(Processor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (re.processingOver()) {
        try {
            FileObject list = filer.createResource(StandardLocation.CLASS_OUTPUT, "",
                    "META-INF/paramanos/bind.list", all.toArray(new Element[0]));
            try (OutputStream out = list.openOutputStream()) {
                out.write(listBuilder.toString().getBytes("UTF-8"));
            }
        } catch (FilerException ex) {
            Logger.getLogger(Processor.class.getName()).log(Level.INFO, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Processor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return true;
}

From source file:org.kie.workbench.common.stunner.core.processors.MainProcessor.java

@Override
protected boolean processWithExceptions(final Set<? extends TypeElement> set, final RoundEnvironment roundEnv)
        throws Exception {
    if (roundEnv.processingOver()) {
        return processLastRound(set, roundEnv);
    }/*from  w ww . j  a v  a  2s  . c o  m*/
    //If prior processing threw an error exit
    if (roundEnv.errorRaised()) {
        return false;
    }
    final Elements elementUtils = processingEnv.getElementUtils();
    // Process Definition Sets types found on the processing environment.
    for (Element e : roundEnv
            .getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_DEFINITION_SET))) {
        processDefinitionSets(set, e, roundEnv);
    }
    // Process Definition types found on the processing environment.
    for (Element e : roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_DEFINITION))) {
        processDefinitions(set, e, roundEnv);
    }
    // Process Property Sets types found on the processing environment
    // AND
    // Process Property Sets types identified as dependant types for the annotated Defininitions. Note that
    // those types cannot be directly found on the processing environment if the classes are in a third party
    // dependency and not directly on the module sources.
    final Set<? extends Element> propertySetElements = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_PROPERTY_SET)));
            addAll(processingContext.getPropertySetElements());
        }
    };
    for (Element e : propertySetElements) {
        processPropertySets(set, e, roundEnv);
    }
    // Process Property types found on the processing environment
    // AND
    // Process PropertySets types identified as dependant types for the annotated Defininitions or Property Sets.
    // Note that // those types cannot be directly found on the processing environment if the classes are in a
    // third party dependency and not directly on the module sources.
    final Set<? extends Element> propertyElements = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_PROPERTY)));
            addAll(processingContext.getPropertyElements());
        }
    };
    for (Element e : propertyElements) {
        processProperties(set, e, roundEnv);
    }
    final Set<? extends Element> containRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_CAN_CONTAIN)));
            addAll(processingContext.getDefinitionElements());
            removeAll(processingContext.getContainmentRuleElementsProcessed());
        }
    };
    for (Element e : containRules) {
        processContainmentRules(e);
    }
    final Set<? extends Element> dockRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_CAN_DOCK)));
            addAll(processingContext.getDefinitionElements());
            removeAll(processingContext.getDockingRuleElementsProcessed());
        }
    };
    for (Element e : dockRules) {
        processDockingRules(e);
    }

    final Set<? extends Element> extRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_EXTENSIONS)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_EXTENSION)));
        }
    };
    for (Element e : extRules) {
        processRuleExtension(e);
    }
    final Set<? extends Element> occRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv
                    .getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_ALLOWED_OCCS)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_OCCS)));
        }
    };
    for (Element e : occRules) {
        processCardinalityRules(e);
    }
    final Set<? extends Element> edgeOccRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(
                    elementUtils.getTypeElement(ANNOTATION_RULE_ALLOWED_EDGE_OCCURRS)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_EDGE_OCCS)));
        }
    };
    for (Element e : edgeOccRules) {
        processEdgeCardinalityRules(e);
    }
    final Set<? extends Element> cRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv
                    .getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_ALLOWED_CONNECTION)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_CAN_CONNECT)));
        }
    };
    for (Element e : cRules) {
        processConnectionRules(e);
    }
    return true;
}

From source file:com.airbnb.deeplinkdispatch.DeepLinkProcessor.java

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Set<Element> customAnnotations = new HashSet<>();
    for (Element annotation : annotations) {
        if (annotation.getAnnotation(DEEP_LINK_SPEC_CLASS) != null) {
            customAnnotations.add(annotation);
        }//ww  w  .  j  a  v a2s  . c o  m
    }

    Map<Element, String[]> prefixes = new HashMap<>();
    Set<Element> customAnnotatedElements = new HashSet<>();
    for (Element customAnnotation : customAnnotations) {
        ElementKind kind = customAnnotation.getKind();
        if (kind != ElementKind.ANNOTATION_TYPE) {
            error(customAnnotation, "Only annotation types can be annotated with @%s",
                    DEEP_LINK_SPEC_CLASS.getSimpleName());
        }
        String[] prefix = customAnnotation.getAnnotation(DEEP_LINK_SPEC_CLASS).prefix();
        if (Utils.hasEmptyOrNullString(prefix)) {
            error(customAnnotation, "Prefix property cannot have null or empty strings");
        }
        if (prefix.length == 0) {
            error(customAnnotation, "Prefix property cannot be empty");
        }
        prefixes.put(customAnnotation, prefix);
        for (Element customAnnotatedElement : roundEnv
                .getElementsAnnotatedWith(MoreElements.asType(customAnnotation))) {
            customAnnotatedElements.add(customAnnotatedElement);
        }
    }

    Set<Element> elementsToProcess = new HashSet<>(customAnnotatedElements);
    elementsToProcess.addAll(roundEnv.getElementsAnnotatedWith(DEEP_LINK_CLASS));

    List<DeepLinkAnnotatedElement> deepLinkElements = new ArrayList<>();
    for (Element element : elementsToProcess) {
        ElementKind kind = element.getKind();
        if (kind != ElementKind.METHOD && kind != ElementKind.CLASS) {
            error(element, "Only classes and methods can be annotated with @%s",
                    DEEP_LINK_CLASS.getSimpleName());
        }

        if (kind == ElementKind.METHOD) {
            Set<Modifier> methodModifiers = element.getModifiers();
            if (!methodModifiers.contains(Modifier.STATIC)) {
                error(element, "Only static methods can be annotated with @%s",
                        DEEP_LINK_CLASS.getSimpleName());
            }
        }

        DeepLink deepLinkAnnotation = element.getAnnotation(DEEP_LINK_CLASS);
        List<String> deepLinks = new ArrayList<>();
        if (deepLinkAnnotation != null) {
            deepLinks.addAll(Arrays.asList(deepLinkAnnotation.value()));
        }
        if (customAnnotatedElements.contains(element)) {
            deepLinks.addAll(enumerateCustomDeepLinks(element, prefixes));
        }
        DeepLinkEntry.Type type = kind == ElementKind.CLASS ? DeepLinkEntry.Type.CLASS
                : DeepLinkEntry.Type.METHOD;
        for (String deepLink : deepLinks) {
            try {
                deepLinkElements.add(new DeepLinkAnnotatedElement(deepLink, element, type));
            } catch (MalformedURLException e) {
                messager.printMessage(Diagnostic.Kind.ERROR, "Malformed Deep Link URL " + deepLink);
            }
        }
    }
    Set<? extends Element> deepLinkHandlerElements = roundEnv.getElementsAnnotatedWith(DeepLinkHandler.class);
    for (Element deepLinkHandlerElement : deepLinkHandlerElements) {
        Optional<AnnotationMirror> annotationMirror = getAnnotationMirror(deepLinkHandlerElement,
                DeepLinkHandler.class);
        if (annotationMirror.isPresent()) {
            Iterable<TypeMirror> klasses = getTypeValue(annotationMirror.get(), "value");
            List<TypeElement> typeElements = FluentIterable.from(klasses)
                    .transform(new Function<TypeMirror, TypeElement>() {
                        @Override
                        public TypeElement apply(TypeMirror klass) {
                            return MoreTypes.asTypeElement(klass);
                        }
                    }).toList();
            String packageName = processingEnv.getElementUtils().getPackageOf(deepLinkHandlerElement)
                    .getQualifiedName().toString();
            try {
                generateDeepLinkDelegate(packageName, typeElements);
            } catch (IOException e) {
                messager.printMessage(Diagnostic.Kind.ERROR, "Error creating file");
            } catch (RuntimeException e) {
                messager.printMessage(Diagnostic.Kind.ERROR,
                        "Internal error during annotation processing: " + e.getClass().getSimpleName());
            }
        }
    }

    Set<? extends Element> deepLinkModuleElements = roundEnv.getElementsAnnotatedWith(DeepLinkModule.class);
    for (Element deepLinkModuleElement : deepLinkModuleElements) {
        String packageName = processingEnv.getElementUtils().getPackageOf(deepLinkModuleElement)
                .getQualifiedName().toString();
        try {
            generateDeepLinkLoader(packageName, deepLinkModuleElement.getSimpleName().toString(),
                    deepLinkElements);
        } catch (IOException e) {
            messager.printMessage(Diagnostic.Kind.ERROR, "Error creating file");
        } catch (RuntimeException e) {
            messager.printMessage(Diagnostic.Kind.ERROR,
                    "Internal error during annotation processing: " + e.getClass().getSimpleName());
        }
    }

    return false;
}

From source file:ca.sqlpower.object.annotation.SPAnnotationProcessor.java

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    for (TypeElement el : annotations) {
        if (!this.annotations.contains(el.getQualifiedName().toString())) {
            return false;
        }/*from www  . ja v a2 s. c  om*/
    }
    Map<Class<? extends SPObject>, SPClassVisitor> visitors = new HashMap<Class<? extends SPObject>, SPClassVisitor>();
    for (Element typeDecl : roundEnv.getElementsAnnotatedWith(Persistable.class)) {
        SPClassVisitor visitor = new SPClassVisitor(typeDecl);
        typeDecl.accept(visitor, null);
        if (visitor.isValid() && visitor.getVisitedClass() != null) {
            visitors.put(visitor.getVisitedClass(), visitor);
        }
    }

    // This block checks if each of the classes has super classes that
    // contain persistable properties. If so, they should inherit those
    // persistable properties. Any additional packages should be
    // imported as well.
    for (Entry<Class<? extends SPObject>, SPClassVisitor> e : visitors.entrySet()) {
        Class<? extends SPObject> superClass = e.getKey();
        SPClassVisitor visitor = e.getValue();

        Multimap<String, String> mutatorImports = HashMultimap.create(visitor.getMutatorImports());
        Map<String, Class<?>> propertiesToAccess = new HashMap<String, Class<?>>(
                visitor.getPropertiesToAccess());
        Multimap<String, String> accessorAdditionalInfo = LinkedHashMultimap
                .create(visitor.getAccessorAdditionalInfo());
        Map<String, Class<?>> propertiesToMutate = new HashMap<String, Class<?>>(
                visitor.getPropertiesToMutate());
        Multimap<String, MutatorParameterObject> mutatorExtraParameters = LinkedHashMultimap
                .create(visitor.getMutatorExtraParameters());
        Multimap<String, Class<? extends Exception>> mutatorThrownTypes = HashMultimap
                .create(visitor.getMutatorThrownTypes());
        Set<String> propertiesToPersistOnlyIfNonNull = new HashSet<String>(
                visitor.getPropertiesToPersistOnlyIfNonNull());

        importedClassNames.clear();

        // Generate the persister helper file if the SPObject class is not abstract.
        if (!Modifier.isAbstract(visitor.getVisitedClass().getModifiers())) {
            generatePersisterHelperFile(superClass, visitor.getConstructorImports(),
                    visitor.getConstructorParameters(), propertiesToAccess, accessorAdditionalInfo,
                    mutatorImports, propertiesToMutate, mutatorExtraParameters, mutatorThrownTypes,
                    propertiesToPersistOnlyIfNonNull);
        } else {
            generateAbstractPersisterHelperFile(superClass, visitor.getConstructorImports(), propertiesToAccess,
                    accessorAdditionalInfo, mutatorImports, propertiesToMutate, mutatorExtraParameters,
                    mutatorThrownTypes, propertiesToPersistOnlyIfNonNull);
        }
    }
    return true;
}

From source file:ch.rasc.extclassgenerator.ModelAnnotationProcessor.java

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,
            "Running " + getClass().getSimpleName());

    if (roundEnv.processingOver() || annotations.size() == 0) {
        return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
    }/*from  w w  w . j  a  v  a  2 s  . c o  m*/

    if (roundEnv.getRootElements() == null || roundEnv.getRootElements().isEmpty()) {
        this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "No sources to process");
        return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
    }

    OutputConfig outputConfig = new OutputConfig();

    outputConfig.setDebug(!"false".equals(this.processingEnv.getOptions().get(OPTION_DEBUG)));
    boolean createBaseAndSubclass = "true"
            .equals(this.processingEnv.getOptions().get(OPTION_CREATEBASEANDSUBCLASS));

    String outputFormatString = this.processingEnv.getOptions().get(OPTION_OUTPUTFORMAT);
    outputConfig.setOutputFormat(OutputFormat.EXTJS4);
    if (StringUtils.hasText(outputFormatString)) {
        if (OutputFormat.TOUCH2.name().equalsIgnoreCase(outputFormatString)) {
            outputConfig.setOutputFormat(OutputFormat.TOUCH2);
        } else if (OutputFormat.EXTJS5.name().equalsIgnoreCase(outputFormatString)) {
            outputConfig.setOutputFormat(OutputFormat.EXTJS5);
        }
    }

    String includeValidationString = this.processingEnv.getOptions().get(OPTION_INCLUDEVALIDATION);
    outputConfig.setIncludeValidation(IncludeValidation.NONE);
    if (StringUtils.hasText(includeValidationString)) {
        if (IncludeValidation.ALL.name().equalsIgnoreCase(includeValidationString)) {
            outputConfig.setIncludeValidation(IncludeValidation.ALL);
        } else if (IncludeValidation.BUILTIN.name().equalsIgnoreCase(includeValidationString)) {
            outputConfig.setIncludeValidation(IncludeValidation.BUILTIN);
        }
    }

    outputConfig.setUseSingleQuotes("true".equals(this.processingEnv.getOptions().get(OPTION_USESINGLEQUOTES)));
    outputConfig.setSurroundApiWithQuotes(
            "true".equals(this.processingEnv.getOptions().get(OPTION_SURROUNDAPIWITHQUOTES)));

    for (TypeElement annotation : annotations) {
        Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(annotation);
        for (Element element : elements) {

            try {
                TypeElement typeElement = (TypeElement) element;

                String qualifiedName = typeElement.getQualifiedName().toString();
                Class<?> modelClass = Class.forName(qualifiedName);

                String code = ModelGenerator.generateJavascript(modelClass, outputConfig);

                Model modelAnnotation = element.getAnnotation(Model.class);
                String modelName = modelAnnotation.value();
                String fileName;
                String packageName = "";
                if (StringUtils.hasText(modelName)) {
                    int lastDot = modelName.lastIndexOf('.');
                    if (lastDot != -1) {
                        fileName = modelName.substring(lastDot + 1);
                        int firstDot = modelName.indexOf('.');
                        if (firstDot < lastDot) {
                            packageName = modelName.substring(firstDot + 1, lastDot);
                        }
                    } else {
                        fileName = modelName;
                    }
                } else {
                    fileName = typeElement.getSimpleName().toString();
                }

                if (createBaseAndSubclass) {
                    code = code.replaceFirst("(Ext.define\\([\"'].+?)([\"'],)", "$1Base$2");
                    FileObject fo = this.processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT,
                            packageName, fileName + "Base.js");
                    OutputStream os = fo.openOutputStream();
                    os.write(code.getBytes(ModelGenerator.UTF8_CHARSET));
                    os.close();

                    try {
                        fo = this.processingEnv.getFiler().getResource(StandardLocation.SOURCE_OUTPUT,
                                packageName, fileName + ".js");
                        InputStream is = fo.openInputStream();
                        is.close();
                    } catch (FileNotFoundException e) {
                        String subClassCode = generateSubclassCode(modelClass, outputConfig);
                        fo = this.processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT,
                                packageName, fileName + ".js");
                        os = fo.openOutputStream();
                        os.write(subClassCode.getBytes(ModelGenerator.UTF8_CHARSET));
                        os.close();
                    }

                } else {
                    FileObject fo = this.processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT,
                            packageName, fileName + ".js");
                    OutputStream os = fo.openOutputStream();
                    os.write(code.getBytes(ModelGenerator.UTF8_CHARSET));
                    os.close();
                }

            } catch (ClassNotFoundException e) {
                this.processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage());
            } catch (IOException e) {
                this.processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage());
            }

        }
    }

    return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}