/** * Recursively visits List type arguments * * @param typeMirror the List type mirror * @return true if the declaration is valid, false otherwise */ private boolean isValidListType( TypeMirror typeMirror ) { return new SimpleTypeVisitor8<Boolean,Void>() { @Override public Boolean visitDeclared( DeclaredType list, Void aVoid ) { List<? extends TypeMirror> typeArguments = list.getTypeArguments(); if ( typeArguments.size() != 1 ) { return false; } return test( typeArguments.get( 0 ) ); } }.visit( typeMirror ); }
/** * Recursively visits Map type arguments * Map key type argument must be a String as of Neo4j stored procedure specification * Map value type argument is recursively visited * * @param typeMirror Map type mirror * @return true if the declaration is valid, false otherwise */ private boolean isValidMapType( TypeMirror typeMirror ) { return new SimpleTypeVisitor8<Boolean,Void>() { @Override public Boolean visitDeclared( DeclaredType map, Void ignored ) { List<? extends TypeMirror> typeArguments = map.getTypeArguments(); if ( typeArguments.size() != 2 ) { return false; } TypeMirror key = typeArguments.get( 0 ); if ( !typeUtils.isSameType( key, typeMirrors.typeMirror( String.class ) ) ) { return false; } return test( typeArguments.get( 1 ) ); } }.visit( typeMirror ); }
public static DeclaredType toDeclaredType(TypeMirror typeMirror, ProcessingEnvironment env) { assertNotNull(typeMirror, env); return typeMirror.accept(new SimpleTypeVisitor8<DeclaredType, Void>() { @Override public DeclaredType visitDeclared(DeclaredType t, Void p) { return t; } }, null); }
public static TypeVariable toTypeVariable(TypeMirror typeMirror, ProcessingEnvironment env) { assertNotNull(typeMirror, env); return typeMirror.accept(new SimpleTypeVisitor8<TypeVariable, Void>() { @Override public TypeVariable visitTypeVariable(TypeVariable t, Void p) { return t; } }, null); }
public static ExecutableType toExecutableType(ExecutableElement element, ProcessingEnvironment env) { assertNotNull(element, env); return element.asType().accept( new SimpleTypeVisitor8<ExecutableType, Void>() { @Override public ExecutableType visitExecutable(ExecutableType t, Void p) { return t; } }, null); }