use of com.twitter.common.args.apt.Configuration.ParserInfo in project commons by twitter.
the class CmdLineProcessor method getParsedTypes.
@Nullable
private Set<String> getParsedTypes(Set<? extends Element> parsers) {
if (!isCheckLinkage) {
return null;
}
Iterable<String> parsersFor = Optional.presentInstances(Iterables.transform(parsers, new Function<Element, Optional<String>>() {
@Override
public Optional<String> apply(Element parser) {
TypeMirror parsedType = getTypeArgument(parser.asType(), typeElement(Parser.class));
if (parsedType == null) {
error("failed to find a type argument for Parser: %s", parser);
return Optional.absent();
}
// Equals on TypeMirrors doesn't work - so we compare string representations :/
return Optional.of(typeUtils.erasure(parsedType).toString());
}
}));
parsersFor = Iterables.concat(parsersFor, Iterables.filter(Iterables.transform(this.persistedConfig.get().parserInfo(), new Function<ParserInfo, String>() {
@Override
@Nullable
public String apply(ParserInfo parserInfo) {
TypeElement typeElement = elementUtils.getTypeElement(parserInfo.parsedType);
// long as the no Args in this round that are of the type.
return (typeElement == null) ? null : typeUtils.erasure(typeElement.asType()).toString();
}
}), Predicates.notNull()));
return ImmutableSet.copyOf(parsersFor);
}
Aggregations