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