Search in sources :

Example 1 with ArgParser

use of com.twitter.common.args.ArgParser in project commons by twitter.

the class CmdLineProcessor method processParsers.

private void processParsers(Set<? extends Element> elements) {
    TypeElement parserType = typeElement(Parser.class);
    for (Element element : elements) {
        if (element.getKind() != ElementKind.CLASS) {
            error("Found an @ArgParser annotation on a non-class %s", element);
        } else {
            TypeElement parser = (TypeElement) element;
            if (!isAssignable(parser, Parser.class)) {
                error("Found an @ArgParser annotation on a non-Parser %s", element);
                return;
            }
            @Nullable String parsedType = getTypeArgument(parser, parserType);
            if (parsedType != null) {
                String parserClassName = getBinaryName(parser);
                getBuilder(parserClassName).addParser(parsedType, getBinaryName(parser));
            }
        }
    }
}
Also used : TypeElement(javax.lang.model.element.TypeElement) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) ExecutableElement(javax.lang.model.element.ExecutableElement) Nullable(javax.annotation.Nullable) ArgParser(com.twitter.common.args.ArgParser) Parser(com.twitter.common.args.Parser)

Aggregations

ArgParser (com.twitter.common.args.ArgParser)1 Parser (com.twitter.common.args.Parser)1 Nullable (javax.annotation.Nullable)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1