Package net.riccardocossu.autodoc.base

Examples of net.riccardocossu.autodoc.base.AnnotatedClass


  @Test
  public void testSimple() {
    PluginFactory factory = new PluginFactory();
    factory.registerPlugin(new JPAPlugin());
    ClassParser parser = new ClassParser();
    AnnotatedClass res = parser.parse(AnnotatedTestEntity.class, factory);
    assertNotNull(res);
    assertEquals(1, res.getAnnotations().size());
    assertEquals(1, res.getFields().size());
    assertEquals(1, res.getMethods().size());
  }
View Full Code Here


  @Test
  public void testEmbedded() {
    PluginFactory factory = new PluginFactory();
    factory.registerPlugin(new JPAPlugin());
    ClassParser parser = new ClassParser();
    AnnotatedClass res = parser.parse(EntityWithEmbeddable.class, factory);
    assertNotNull(res);
    assertEquals(2, res.getAnnotations().size());
    assertEquals(1, res.getFields().size());
    assertEquals(0, res.getMethods().size());
  }
View Full Code Here

  @Test
  public void testNonJpa() {
    PluginFactory factory = new PluginFactory();
    factory.registerPlugin(new JPAPlugin());
    ClassParser parser = new ClassParser();
    AnnotatedClass res = parser.parse(NonJPATestEntity.class, factory);
    assertNull(res);
  }
View Full Code Here

          .getTopLevelClassesRecursive(packagetoParse)) {
        packClasses.add(classInfo.load());
      }
      for (Class<?> c : packClasses) {
        log.debug("Parsing class {}", c.getName());
        AnnotatedClass ac = classParser.parse(c, factory);
        if (ac != null) {
          classes.add(ac);
        }
      }
    } catch (Exception e) {
View Full Code Here

   * @return the parsed class model, or <code>null</code> if no plugin is
   *         interested in it
   */
  public AnnotatedClass parse(@SuppressWarnings("rawtypes") Class clazz,
      PluginFactory factory) {
    AnnotatedClass ac = null;
    Annotation[] annotations = clazz.getDeclaredAnnotations();
    if (factory.isClassUseful(clazz, annotations)) {
      ac = new AnnotatedClass();
      ac.setQualifiedName(clazz.getName());
      AnnotationsPlugin pl = null;
      Annotation[] declaredAnnotations = null;
      for (Annotation a : annotations) {
        pl = factory.getPluginForAnnotation(a.annotationType());
        if (pl != null) {
          ac.getAnnotations().add(pl.parse(a));
        }
      }
      Field[] fields = clazz.getDeclaredFields();
      for (Field f : fields) {
        declaredAnnotations = f.getDeclaredAnnotations();
        if (factory.isFieldUseful(f, declaredAnnotations)) {
          AnnotatedField af = new AnnotatedField();
          af.setName(f.getName());
          af.setType(f.getType().getName());
          for (Annotation a : declaredAnnotations) {
            pl = factory.getPluginForAnnotation(a.annotationType());
            if (pl != null) {
              af.getAnnotations().add(pl.parse(a));
            }
          }
          ac.getFields().add(af);
        }
      }
      Method[] methods = clazz.getDeclaredMethods();
      for (Method m : methods) {
        declaredAnnotations = m.getDeclaredAnnotations();
        if (factory.isMethodUseful(m, declaredAnnotations)) {
          AnnotatedMethod am = new AnnotatedMethod();
          am.setName(m.getName());
          am.setReturnType(m.getReturnType().getName());
          for (Annotation a : declaredAnnotations) {
            pl = factory.getPluginForAnnotation(a.annotationType());
            if (pl != null) {
              am.getAnnotations().add(pl.parse(a));
            }
          }
          ac.getMethods().add(am);
        }
      }
    }
    return ac;
  }
View Full Code Here

TOP

Related Classes of net.riccardocossu.autodoc.base.AnnotatedClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.