Examples of AnnotatedClass


Examples of net.riccardocossu.autodoc.base.AnnotatedClass

   * @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

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

    //////////////////////////////////////////////
     */

    public void testSimple()
    {
        AnnotatedClass ac = AnnotatedClass.constructFull
            (SubClass.class, JacksonAnnotationFilter.instance, true, BasicClassIntrospector.GetterMethodFilter.instance);

        assertNotNull(ac.getDefaultConstructor());
        assertEquals(1, ac.getSingleArgConstructors().size());
        assertEquals(0, ac.getSingleArgStaticMethods().size());
        assertEquals(2, ac.getMemberMethods().size());
        for (AnnotatedMethod am : ac.getMemberMethods()) {
            String name = am.getName();
            if ("y".equals(name)) {
                assertEquals(0, am.getAnnotationCount());
            } else if ("x".equals(name)) {
                assertEquals(1, am.getAnnotationCount());
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

     * Another simple test to verify that the (concrete) type information
     * from a sub-class is used instead of abstract one from superclass.
     */
    public void testGenericsWithSetter()
    {
        AnnotatedClass ac = AnnotatedClass.constructFull
            (NumberBean.class, JacksonAnnotationFilter.instance, true, BasicClassIntrospector.SetterMethodFilter.instance);
        Collection<AnnotatedMethod> methods = ac.getMemberMethods();
        assertEquals(1, methods.size());

        AnnotatedMethod am = methods.iterator().next();

        assertEquals("setX", am.getName());
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

    @SuppressWarnings("deprecation")
    public void testSimple()
    {
        // null -> no mix-in annotations
        AnnotatedClass ac = AnnotatedClass.construct(SubClass.class, new JacksonAnnotationIntrospector(), null);
        ac.resolveMemberMethods(BasicClassIntrospector.DEFAULT_GETTER_FILTER);
        ac.resolveCreators(true);
        ac.resolveFields();

        assertNotNull(ac.getDefaultConstructor());
        assertEquals(1, ac.getConstructors().size());
        assertEquals(0, ac.getStaticMethods().size());
        assertEquals(2, ac.getMemberMethodCount());
        for (AnnotatedMethod am : ac.memberMethods()) {
            String name = am.getName();
            if ("y".equals(name)) {
                assertEquals(0, am.getAnnotationCount());
            } else if ("x".equals(name)) {
                assertEquals(1, am.getAnnotationCount());
                assertNotNull(am.getAnnotation(JsonProperty.class));
            } else {
                fail("Unexpected method: "+name);
            }
        }
        assertEquals(1, ac.getFieldCount());
        assertEquals("foo", ac.fields().iterator().next().getName());
    }
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

     */
    @SuppressWarnings("deprecation")
    public void testGenericsWithSetter()
    {
        // null -> no mix-in annotations
        AnnotatedClass ac = AnnotatedClass.construct(NumberBean.class, new JacksonAnnotationIntrospector(), null);
        ac.resolveMemberMethods(BasicClassIntrospector.DEFAULT_SETTER_FILTER);
        assertEquals(1, ac.getMemberMethodCount());

        Iterator<AnnotatedMethod> it = ac.memberMethods().iterator();
        AnnotatedMethod am = it.next();

        assertEquals("setX", am.getName());
        // should be one from sub-class
        assertEquals(NumberBean.class, am.getDeclaringClass());
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

    }

    public void testFieldIntrospection()
    {
        // null -> no mix-in annotations
        AnnotatedClass ac = AnnotatedClass.construct(FieldBean.class, new JacksonAnnotationIntrospector(), null);
        ac.resolveFields();
        /* 14-Jul-2009, tatu: AnnotatedClass does remove forcibly ignored
         *   entries, but will still contain non-public fields too (earlier
         *   versions didn't, but filtering was moved to a later point)
         */
        assertEquals(2, ac.getFieldCount());
        for (AnnotatedField f : ac.fields()) {
            String fname = f.getName();
            if (!"bar".equals(fname) && !"props".equals(fname)) {
                fail("Unexpected field name '"+fname+"'");
            }
        }
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

    public void testSimpleOther() throws Exception
    {
        // Let's use Jackson+JAXB comb
        AnnotationIntrospector ann = new AnnotationIntrospector.Pair(_jacksonAI, _jaxbAI);

        AnnotatedClass testClass = AnnotatedClass.construct(NamedBean.class, ann, null);
        assertNull(ann.findCachability(testClass));
        //assertNull(ann.findSerializationInclusion(testClass, null));

        JavaType type = TypeFactory.type(Object.class);
        assertNull(ann.findDeserializationType(testClass, type, null));
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

        /* 10-Jul-2009, tatu: Should be able to just pass null as
         *    'MixInResolver'; no mix-ins set at this point
         */
        AnnotationIntrospector ai = getAnnotationIntrospector();
        AnnotatedClass ac = AnnotatedClass.construct(cls, ai, null);
        // visibility checks handled via separate checker object...
        VisibilityChecker<?> prevVc = getDefaultVisibilityChecker();
        _base = _base.withVisibilityChecker(ai.findAutoDetectVisibility(ac, prevVc));
    }
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

        if (!addToCache) {
            // 14-Feb-2011, tatu: As per [JACKSON-487], try fully blocking annotation access:
            if (config.isEnabled(DeserializationConfig.Feature.USE_ANNOTATIONS)) {
                AnnotationIntrospector aintr = config.getAnnotationIntrospector();
                // note: pass 'null' to prevent mix-ins from being used
                AnnotatedClass ac = AnnotatedClass.construct(deser.getClass(), aintr, null);
                Boolean cacheAnn = aintr.findCachability(ac);
                if (cacheAnn != null) {
                    addToCache = cacheAnn.booleanValue();
                }
            }
View Full Code Here

Examples of org.codehaus.jackson.map.introspect.AnnotatedClass

                return name;
            }
        }
        BasicBeanDescription beanDesc = (BasicBeanDescription) config.introspectClassAnnotations(rootType);
        AnnotationIntrospector intr = config.getAnnotationIntrospector();
        AnnotatedClass ac = beanDesc.getClassInfo();
        String nameStr = intr.findRootName(ac);
        // No answer so far? Let's just default to using simple class name
        if (nameStr == null) {
            // Should we strip out enclosing class tho? For now, nope:
            nameStr = rootType.getSimpleName();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.