public ClassGraph whitelistClasses ( final String ... classNames ) { enableClassInfo ( ) ; for ( final String className : classNames ) { if ( className . contains ( "*" ) ) { throw new IllegalArgumentException ( "Cannot use a glob wildcard here: " + className ) ; } final String classNameNormalized = WhiteBlackList . normalizePackageOrClassName ( className ) ; // Whitelist the class itself scanSpec . classWhiteBlackList . addToWhitelist ( classNameNormalized ) ; scanSpec . classfilePathWhiteBlackList . addToWhitelist ( WhiteBlackList . classNameToClassfilePath ( classNameNormalized ) ) ; final String packageName = PackageInfo . getParentPackageName ( classNameNormalized ) ; // Record the package containing the class, so we can recurse to this point even if the package // is not itself whitelisted scanSpec . classPackageWhiteBlackList . addToWhitelist ( packageName ) ; scanSpec . classPackagePathWhiteBlackList . addToWhitelist ( WhiteBlackList . packageNameToPath ( packageName ) + "/" ) ; } return this ; }
Scan one or more specific classes without scanning other classes in the same package unless the package is itself whitelisted .