Package org.jboss.reflect.spi

Examples of org.jboss.reflect.spi.ClassInfo


         TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
         AnnotationValue[][] paramAnnotations = new AnnotationValue[paramClasses.length][0];
         int i = 0;
         for (Class<?> c : paramClasses)
            paramTypes[i++] = factory.getTypeInfo(c);
         ClassInfo classInfo = (ClassInfo) factory.getTypeInfo(method.getDeclaringClass());
         MethodInfo m = new MethodInfoImpl(null, method.getName(), returnType, paramTypes, paramAnnotations, null, method.getModifiers(), classInfo);
         expected.add(m);
      }
     
      Set<MethodInfo> actual = beanInfo.getMethods();
View Full Code Here


               merged.addAll(setterAnnotations);
               annotations = merged.toArray(new AnnotationValue[merged.size()]);
            }
           
            TypeInfo type = factory.getTypeInfo(getter.getGenericReturnType());
            ClassInfo declaringType = (ClassInfo) factory.getTypeInfo(getter.getDeclaringClass());
            MethodInfo getterInfo = new MethodInfoImpl(null, getter.getName(), type, new TypeInfo[0], null, null, getter.getModifiers(), declaringType);
            MethodInfo setterInfo = null;
            if (setter != null)
            {
               declaringType = (ClassInfo) factory.getTypeInfo(setter.getDeclaringClass());
               AnnotationValue[][] paramAnnotations = new AnnotationValue[1][];
               setterAnnotations = getExpectedAnnotations(setter.getParameterAnnotations()[0]);
               paramAnnotations[0] = setterAnnotations.toArray(new AnnotationValue[setterAnnotations.size()]);
               setterInfo = new MethodInfoImpl(null, setter.getName(), PrimitiveInfo.VOID, new TypeInfo[] { type }, paramAnnotations, null, setter.getModifiers(), declaringType);
            }
            properties.put(lowerName, new DefaultPropertyInfo(lowerName, name, type, getterInfo, setterInfo, annotations));
         }
      }
      if (setters.isEmpty() == false)
      {
         for (Iterator<Map.Entry<String, List<Method>>> i = setters.entrySet().iterator(); i.hasNext();)
         {
            Map.Entry<String, List<Method>> entry = i.next();
            String name = entry.getKey();
            List<Method> setterList = entry.getValue();
            // TODO JBMICROCONT-125 Maybe should just create duplicate propertyInfo and let the configurator guess?
            if (setterList.size() == 1)
            {
               Method setter = setterList.get(0);
               Type pinfo = setter.getGenericParameterTypes()[0];
               TypeInfo type = factory.getTypeInfo(pinfo);
               String lowerName = getLowerPropertyName(name);
               Set<AnnotationValue> setterAnnotations = getExpectedAnnotations(setter.getAnnotations());
               AnnotationValue[] annotations = setterAnnotations.toArray(new AnnotationValue[setterAnnotations.size()]);
               ClassInfo declaringType = (ClassInfo) factory.getTypeInfo(setter.getDeclaringClass());
               AnnotationValue[][] paramAnnotations = new AnnotationValue[1][];
               setterAnnotations = getExpectedAnnotations(setter.getParameterAnnotations()[0]);
               paramAnnotations[0] = setterAnnotations.toArray(new AnnotationValue[setterAnnotations.size()]);
               MethodInfo setterInfo = new MethodInfoImpl(null, setter.getName(), PrimitiveInfo.VOID, new TypeInfo[] { type }, paramAnnotations, null, setter.getModifiers(), declaringType);
               properties.put(lowerName, new DefaultPropertyInfo(lowerName, name, type, null, setterInfo, annotations));
            }
         }
      }
      if (mode != BeanAccessMode.STANDARD)
      {
         ClassInfo classInfo = (ClassInfo)factory.getTypeInfo(clazz);
         Set<FieldInfo> fields = getFields(classInfo, mode);
         for(FieldInfo field : fields)
         {
            String name = field.getName();
            PropertyInfo pi = properties.get(name);
View Full Code Here

         TypeInfo returnType = factory.getTypeInfo(method.getGenericReturnType());
         Class<?>[] parameters = method.getParameterTypes();
         if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
         {
            String name = method.getName();
            ClassInfo declaringType = (ClassInfo) factory.getTypeInfo(method.getDeclaringClass());
            Set<AnnotationValue> getterAnnotations = getExpectedAnnotations(method.getAnnotations());
            AnnotationValue[] annotations = getterAnnotations.toArray(new AnnotationValue[getterAnnotations.size()]);
            MethodInfo getter = new MethodInfoImpl(null, name, returnType, new TypeInfo[0], new AnnotationValue[0][], null, method.getModifiers(), declaringType);
            properties.add(new DefaultPropertyInfo(name, name, returnType, getter, null, annotations));
         }
View Full Code Here

      super(name);
   }
  
   public void testClassAnnotations() throws Exception
   {
      ClassInfo info = getClassInfo(AnnotatedClass.class);

      checkAnnotations(info, CLASS_DATA);
   }
View Full Code Here

      checkAnnotations(info, CLASS_DATA);
   }
  
   public void testSubClassAnnotations() throws Exception
   {
      ClassInfo info = getClassInfo(AnnotatedSubClass.class);

      System.out.println("---> Getting annotations");
      AnnotationValue[] annotations = info.getAnnotations();
      assertEquals(2, annotations.length);
      AnnotationValue anotherAnnotation = getAnnotationCheckTypeAndName(info, AnotherAnnotation.class.getName());
      AnnotationValue simpleAnnotation = getAnnotationCheckTypeAndName(info, SimpleAnnotation.class.getName());
     
      HashSet<AnnotationValue> set = new HashSet<AnnotationValue>();
      set.add(anotherAnnotation);
      set.add(simpleAnnotation);
     
      for (int i = 0 ; i < annotations.length ; i++)
      {
         set.remove(annotations[i]);
      }
     
      assertTrue("Not found annotations " + set, set.isEmpty());
    
      ConstructorInfo[] ctors = info.getDeclaredConstructors();
      assertEquals(1, ctors.length);
      ConstructorInfo ctor = ctors[0];
      annotations = ctor.getAnnotations();
      assertEquals(1, annotations.length);
      anotherAnnotation = getAnnotationCheckTypeAndName(ctor, AnotherAnnotation.class.getName());
View Full Code Here

  
   public void testClassArrayAnnotations() throws Exception
   {
      Class<?> classArray = new AnnotatedClass[0].getClass();
     
      ClassInfo info = getClassInfo(classArray);
      assertTrue(ArrayInfo.class.isAssignableFrom(info.getClass()));
     
      assertTrue(info.getAnnotations().length == 0);
      for (Class <?>annotation : EXPECTED_ANNOTATIONS)
      {
         assertNull(info.getAnnotation(annotation.getName()));
         assertFalse(info.isAnnotationPresent(annotation.getName()));
      }
     
      ClassInfo componentInfo = (ClassInfo)((ArrayInfo)info).getComponentType();
      checkAnnotations(componentInfo, CLASS_DATA);
   }
View Full Code Here

  
   public void testSubClassArrayAnnotations() throws Exception
   {
      Class<?> classArray = new AnnotatedSubClass[0].getClass();
     
      ClassInfo info = getClassInfo(classArray);
      assertTrue(ArrayInfo.class.isAssignableFrom(info.getClass()));

      assertTrue(info.getAnnotations().length == 0);
      assertNull(info.getAnnotation(AnotherAnnotation.class.getName()));
      assertFalse(info.isAnnotationPresent(AnotherAnnotation.class.getName()));
      assertNull(info.getAnnotation(SimpleAnnotation.class.getName()));
      assertFalse(info.isAnnotationPresent(SimpleAnnotation.class.getName()));
     
      ClassInfo componentInfo = (ClassInfo)((ArrayInfo)info).getComponentType();
      AnnotationValue[] annotations = componentInfo.getAnnotations();
      assertEquals(2, annotations.length);
      AnnotationValue anotherAnnotation = getAnnotationCheckTypeAndName(componentInfo, AnotherAnnotation.class.getName());
      AnnotationValue simpleAnnotation = getAnnotationCheckTypeAndName(componentInfo, SimpleAnnotation.class.getName());
     
      HashSet<AnnotationValue> set = new HashSet<AnnotationValue>();
View Full Code Here

  
  
  
   public void testConstructorAnnotations() throws Exception
   {
      ClassInfo info = getClassInfo(AnnotatedClass.class);
     
      ConstructorInfo[] constructors = info.getDeclaredConstructors();
      assertEquals(1, constructors.length);

      checkAnnotations(constructors[0], CONSTRUCTOR_DATA);
   }
View Full Code Here

      checkAnnotations(constructors[0], CONSTRUCTOR_DATA);
   }
  
   public void testFieldAnnotations() throws Exception
   {
      ClassInfo info = getClassInfo(AnnotatedClass.class);

      FieldInfo[] fields = info.getDeclaredFields();
      assertEquals(1, fields.length);

      checkAnnotations(fields[0], FIELD_DATA);
   }
View Full Code Here

      checkAnnotations(fields[0], FIELD_DATA);
   }
  
   public void testMethodAnnotations() throws Exception
   {
      ClassInfo info = getClassInfo(AnnotatedClass.class);
     
      MethodInfo[] methods = info.getDeclaredMethods();
      assertEquals(1, methods.length);

      checkAnnotations(methods[0], METHOD_DATA);
   }
View Full Code Here

TOP

Related Classes of org.jboss.reflect.spi.ClassInfo

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.