@SuppressWarnings("unchecked") // Verified via calls to isAssignableFrom()
    private Collection<Class<? extends Identifiable>> getDirectoryTypes() {

        Set<Class<? extends Identifiable>> types = new HashSet<>();

        Method[] methods = UserContext.class.getMethods();
        for (Method method : methods) {

            if (!Directory.class.isAssignableFrom(method.getReturnType()))
                continue;

            Type retType = method.getGenericReturnType();
            Assert.assertTrue("UserContext functions that return directories "
                    + "must have proper type parameters for the returned "
                    + "directory.", retType instanceof ParameterizedType);

            Type[] typeArgs = ((ParameterizedType) retType).getActualTypeArguments();
            Assert.assertEquals("UserContext functions that return directories "
                    + "must properly declare exactly one type argument for "
                    + "those directories.", 1, typeArgs.length);

            Class<?> directoryType = (Class<?>) typeArgs[0];
            Assert.assertTrue("Directories returned by UserContext functions "
                    + "must contain subclasses of Identifiable.",
                    Identifiable.class.isAssignableFrom(directoryType));

            types.add((Class<? extends Identifiable>) directoryType);

        }

        return Collections.unmodifiableSet(types);

    }
Returns a Collection of all classes that have associated Directories
available via the UserContext interface. The classes are retrieved
using reflection by enumerating the type parameters of the return types
of all functions that return a Directory.

@return
    A Collection of all classes that have associated Directories
    available via the UserContext interface.
guacamole-ext/src/test/java/org/apache/guacamole/net/auth/DirectoryTest.java