String (String className) { for (int dotPos = className.lastIndexOf('.'); dotPos > 0; dotPos = className.lastIndexOf('.', dotPos - 1)) { String packageName = className.substring(0, dotPos); Boolean isPackage = myPackages.computeIfAbsent(packageName, this::isExistingPackage); if (isPackage) { return packageName; } } return null; }