### Question:
BeanFilter { public List<String> getBeanFields(Class<?> bean, int depth) { List<String> fields = Lists.newLinkedList(); for (Method method : bean.getMethods()) { if (method.getName().startsWith("get")) { String fieldName = method.getName().substring(3); fields.add(fieldName); Class<?> returnType = method.getReturnType(); if (List.class.isAssignableFrom(returnType)) { ParameterizedType aType = (ParameterizedType) method.getGenericReturnType(); Type[] parameterArgTypes = aType.getActualTypeArguments(); if (parameterArgTypes.length > 0) { returnType = (Class<?>) parameterArgTypes[0]; } else { returnType = null; } } if (Map.class.isAssignableFrom(returnType)) { ParameterizedType aType = (ParameterizedType) method.getGenericReturnType(); Type[] parameterArgTypes = aType.getActualTypeArguments(); if (parameterArgTypes.length > 1) { returnType = (Class<?>) parameterArgTypes[1]; } else { returnType = null; } } if (depth > 1 && returnType != null && !returnType.isPrimitive() && !returnType.isEnum() && !BeanDelegator.PRIMITIVE_TYPE_CLASSES.contains(returnType)) { List<String> subFields = getBeanFields(returnType, depth - 1); for (String field : subFields) { fields.add(fieldName + DELIMITER + field); } } } } return fields; }  Object createFilteredBean(Object data, Set<String> fields); Set<String> processBeanFields(Collection<String> fields); List<String> getBeanFields(Class<?> bean, int depth); static final String ALL_FIELDS; static final String DELIMITER; }### Answer:
@Test public void testListFields() { List<String> fields = beanFilter.getBeanFields(SimpleBeanInterface.class, 3); assertTrue(fields.contains("Map")); assertTrue(fields.contains("I")); assertTrue(fields.contains("S")); assertTrue(fields.contains("Style")); assertTrue(fields.contains("List")); assertTrue(fields.contains("BeanList.List")); assertTrue(fields.contains("Map")); assertTrue(fields.contains("BeanMap.List")); assertTrue(fields.contains("BeanMap.BeanMap.BeanMap")); assertFalse(fields.contains("BeanMap.BeanMap.BeanMap.BeanMap")); assertEquals(77, fields.size()); }