1package my.packagez; 2 3import com.github.javaparser.ast.Node; 4import com.github.javaparser.ast.body.BodyDeclaration; 5import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; 6import com.github.javaparser.ast.body.MethodDeclaration; 7import com.github.javaparser.ast.body.TypeDeclaration; 8import com.github.javaparser.ast.expr.NameExpr; 9 10import java.util.Optional; 11 12/** 13 * This class can be used to conveniently retrieve certain node from a JavaParser AST. 14 */ 15public final class Navigator { 16 17 private Navigator() { 18 // prevent instantiation 19 } 20 21 public static Optional<TypeDeclaration> findType(CompilationUnit cu, String name) { 22 return cu.getTypes().stream().filter((t) -> t.getName().equals(name)).findFirst(); 23 } 24 25}