本文整理汇总了Java中javax.lang.model.util.SimpleTypeVisitor7类的典型用法代码示例。如果您正苦于以下问题:Java SimpleTypeVisitor7类的具体用法?Java SimpleTypeVisitor7怎么用?Java SimpleTypeVisitor7使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleTypeVisitor7类属于javax.lang.model.util包,在下文中一共展示了SimpleTypeVisitor7类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import javax.lang.model.util.SimpleTypeVisitor7; //导入依赖的package包/类
@Override
public void process(Element element) throws Exception {
final Element enclosingElement = element.getEnclosingElement();
if (enclosingElement.getAnnotation(Entry.class) == null) {
throw new ElementException("Class containing @Relation must be annotated with @Entry", enclosingElement);
}
element.asType().accept(new SimpleTypeVisitor7<Void, Void>() {
@Override
public Void visitDeclared(DeclaredType t, Void unused) {
final List<? extends TypeMirror> args = t.getTypeArguments();
if (args.isEmpty()) {
processOneToOne(element, t.asElement());
} else {
processOneToMany(element, (TypeElement) t.asElement(), args.get(0));
}
return super.visitDeclared(t, unused);
}
}, null);
}
示例2: processOneToMany
import javax.lang.model.util.SimpleTypeVisitor7; //导入依赖的package包/类
private void processOneToMany(Element field, Element collectionType, TypeMirror relation) {
if (!mTypeUtils.isAssignable(collectionType.asType(), List.class)) {
throw new ElementException("Relation type must be subclass of List<E>", field);
}
relation.accept(new SimpleTypeVisitor7<Void, Void>() {
@Override
public Void visitDeclared(DeclaredType t, Void unused) {
final Element element = t.asElement();
if (element.getAnnotation(Entry.class) == null) {
throw new ElementException("Related type must be annotated with @Entry", element);
}
final Element enclosingElement = field.getEnclosingElement();
final TableSpec lTable = mCompileGraph.findTableSpec(enclosingElement);
final TableSpec rTable = mCompileGraph.findTableSpec(element);
final ClassName className = makeClassName(field);
final RelationSpec relationSpec = new RelationSpec(
field, className, lTable, rTable, true);
mCompileGraph.putRelationSpec(enclosingElement, relationSpec);
return super.visitDeclared(t, unused);
}
}, null);
}
示例3: forTypeMirror
import javax.lang.model.util.SimpleTypeVisitor7; //导入依赖的package包/类
public TypeName forTypeMirror(TypeMirror mirror) {
return mirror.accept(new SimpleTypeVisitor7<TypeName, Void>(){
}, null);
}