BeanAnalyzer { public static Map<String, PropertyDescriptor> getAllProperties(GenericType root) throws IntrospectionException { Map<String, PropertyDescriptor> properties = cPropertiesCache.get(root); if (properties == null) { GenericType rootType = root.getRootType(); if (rootType == null) { rootType = root; } properties = Collections.unmodifiableMap ( createProperties(rootType, root) ); cPropertiesCache.put(root, properties); } return properties; }  static Map<String, PropertyDescriptor> getAllProperties(GenericType root); static final String LENGTH_PROPERTY_NAME; static final String KEYED_PROPERTY_NAME; static final String ELEMENT_TYPE_FIELD_NAME; }
@Test public void testCovariants() throws Exception { Map<String, PropertyDescriptor> properties = BeanAnalyzer.getAllProperties(new GenericType(Int.class)); PropertyDescriptor value = properties.get("value"); assertEquals(Integer.class, value.getPropertyType()); assertEquals(Integer.class, value.getReadMethod().getReturnType()); }
@Test public void testGenerics() throws Exception { Map<String, PropertyDescriptor> properties = BeanAnalyzer.getAllProperties(new GenericType(IntGenerics.class)); PropertyDescriptor value = properties.get("value"); assertEquals(Integer.class, value.getPropertyType()); assertEquals(Integer.class, value.getReadMethod().getReturnType()); assertEquals(Integer.class, value.getWriteMethod().getParameterTypes()[0]); }