Set<C> (C baseClass) { Set<C> result = myTargetClassToExtendingMap.get(baseClass); if(result == null) { result = new HashSet<>(); result.add(baseClass); final Set<C> allClasses = getAllClasses(); for (C aClass : allClasses) { if (isInheritor(baseClass, aClass)) { result.add(aClass); } } myTargetClassToExtendingMap.put(baseClass, result); } return result; }