### Question:
PropertyAccessorHelper { public static Class<?> getGenericClass(Field collectionField) { Class<?> genericClass = null; if (collectionField == null) { return genericClass; } if (isCollection(collectionField.getType())) { Type[] parameters = ReflectUtils.getTypeArguments(collectionField); if (parameters != null) { if (parameters.length == 1) { genericClass = toClass(parameters[0]); } else { throw new PropertyAccessException( "Can't determine generic class from a field that has more than one parameters."); } } } if (collectionField.getType().isAssignableFrom(Map.class)) { java.lang.reflect.Type[] arguments = ((ParameterizedType) collectionField.getGenericType()) .getActualTypeArguments(); if (arguments != null && arguments.length > 1) { genericClass = getTypedClass(arguments[1]); } } return genericClass != null ? genericClass : collectionField.getType(); }  static void set(Object target, Field field, byte[] bytes); static void set(Object target, Field field, String fieldVal); static void set(Object target, Field field, Object value); static Object getObject(Object from, Field field); static Object getObjectCopy(Object from, Field field); static String getString(Object from, Field field); static byte[] get(Object from, Field field); static Object getId(Object entity, EntityMetadata metadata); static void setId(Object entity, EntityMetadata metadata, Object rowKey); static void setId(Object entity, EntityMetadata metadata, byte[] rowKey); @SuppressWarnings("null") // TODO: Too much code, improve this, possibly by breaking it static final Object getObject(Object obj, String fieldName); static Class<?> getGenericClass(Field collectionField); static List<Class<?>> getGenericClasses(Field collectionField); static Field[] getDeclaredFields(Field relationalField); static final boolean isCollection(Class<?> clazz); static final Object getObject(Class<?> clazz); static final byte[] toBytes(Object o, Field f); static final byte[] toBytes(Object o, Class c); static Object fromSourceToTargetClass(Class<?> targetClass, Class<?> sourceClass, Object o); static Object fromDate(Class<?> targetClass, Class<?> sourceClass, Object o); static byte[] getBytes(Object o); static String getString(Object o); static Object getObject(Class clazz, byte[] b); static final Collection getCollectionInstance(Field collectionField);  }### Answer:
@Test public void testGetGenericClass() { Assert.assertNull(PropertyAccessorHelper.getGenericClass(null)); try { Class<?> genericClass = PropertyAccessorHelper.getGenericClass(PhotographerUni_1_M_1_M.class.getDeclaredField("albums")); Assert.assertEquals(AlbumUni_1_M_1_M.class, genericClass); } catch (SecurityException e) { Assert.fail(e.getMessage()); } catch (NoSuchFieldException e) { Assert.fail(e.getMessage()); } }