EntitySourceAnalyzer { public List<EntityField> analyze(File source) throws IOException, ParseException { List<EntityField> entityFields = new ArrayList<>(); CompilationUnit cu = JavaParser.parse(source); cu.accept(new VoidVisitorAdapter<List<EntityField>>() { @Override public void visit(FieldDeclaration fd, List<EntityField> f) { if (fd.getAnnotations().stream().anyMatch(anno -> anno.getName().getName().equals("Column"))) { Class<?> type = null; switch (fd.getType().toString()) { case "String": type = String.class; break; case "Long": type = Long.class; break; case "Integer": type = Integer.class; break; case "boolean": type = boolean.class; break; } if (type == null) return; f.add(new EntityField( fd.getVariables().get(0).getId().getName(), type, fd.getAnnotations().stream().anyMatch(anno -> anno.getName().getName().equals("Id")))); } } }, entityFields); return entityFields; }  List<EntityField> analyze(File source);  }
@Test void test() throws Exception { EntitySourceAnalyzer analyzer = new EntitySourceAnalyzer(); List<EntityField> fields = analyzer.analyze(new File("src/test/resources/Product.java")); System.out.println(fields); }