src/main/java/io/github/classgraph/ClassInfo.java
private static Set<ClassInfo> filterClassInfo(final Collection<ClassInfo> classes, final ScanSpec scanSpec,
            final boolean strictWhitelist, final ClassType... classTypes) {
        if (classes == null) {
            return Collections.<ClassInfo> emptySet();
        }
        boolean includeAllTypes = classTypes.length == 0;
        boolean includeStandardClasses = false;
        boolean includeImplementedInterfaces = false;
        boolean includeAnnotations = false;
        for (final ClassType classType : classTypes) {
            switch (classType) {
            case ALL:
                includeAllTypes = true;
                break;
            case STANDARD_CLASS:
                includeStandardClasses = true;
                break;
            case IMPLEMENTED_INTERFACE:
                includeImplementedInterfaces = true;
                break;
            case ANNOTATION:
                includeAnnotations = true;
                break;
            case INTERFACE_OR_ANNOTATION:
                includeImplementedInterfaces = includeAnnotations = true;
                break;
            default:
                throw new IllegalArgumentException("Unknown ClassType: " + classType);
            }
        }
        if (includeStandardClasses && includeImplementedInterfaces && includeAnnotations) {
            includeAllTypes = true;
        }
        final Set<ClassInfo> classInfoSetFiltered = new LinkedHashSet<>(classes.size());
        for (final ClassInfo classInfo : classes) {
            // Check class type against requested type(s)
            if ((includeAllTypes //
                    || includeStandardClasses && classInfo.isStandardClass()
                    || includeImplementedInterfaces && classInfo.isImplementedInterface()
                    || includeAnnotations && classInfo.isAnnotation()) //
                    // Always check blacklist 
                    && !scanSpec.classOrPackageIsBlacklisted(classInfo.name) //
                    // Always return whitelisted classes, or external classes if enableExternalClasses is true
                    && (!classInfo.isExternalClass || scanSpec.enableExternalClasses
                    // Return external (non-whitelisted) classes if viewing class hierarchy "upwards" 
                            || !strictWhitelist)) {
                // Class passed strict whitelist criteria
                classInfoSetFiltered.add(classInfo);
            }
        }
        return classInfoSetFiltered;
    }
/**
     * Filter classes according to scan spec and class type.
     *
     * @param classes
     *            the classes
     * @param scanSpec
     *            the scan spec
     * @param strictWhitelist
     *            If true, exclude class if it is is external, blacklisted, or a system class.
     * @param classTypes
     *            the class types
     * @return the filtered classes.
     */
Filter classes according to scan spec and class type.
@param classes
the classes
@param scanSpec
the scan spec
@param strictWhitelist
If true, exclude class if it is is external, blacklisted, or a system class.
@param classTypes
the class types
@return the filtered classes.
Filter classes according to scan spec and class type . @param classes the classes @param scanSpec the scan spec @param strictWhitelist If true exclude class if it is is external blacklisted or a system class . @param classTypes the class types @return the filtered classes .
private static Set<ClassInfo> filterClassInfo(final Collection<ClassInfo> classes, final ScanSpec scanSpec,
            final boolean strictWhitelist, final ClassType... classTypes) {
        if (classes == null) {
            return Collections.<ClassInfo> emptySet();
        }
        boolean includeAllTypes = classTypes.length == 0;
        boolean includeStandardClasses = false;
        boolean includeImplementedInterfaces = false;
        boolean includeAnnotations = false;
        for (final ClassType classType : classTypes) {
            switch (classType) {
            case ALL:
                includeAllTypes = true;
                break;
            case STANDARD_CLASS:
                includeStandardClasses = true;
                break;
            case IMPLEMENTED_INTERFACE:
                includeImplementedInterfaces = true;
                break;
            case ANNOTATION:
                includeAnnotations = true;
                break;
            case INTERFACE_OR_ANNOTATION:
                includeImplementedInterfaces = includeAnnotations = true;
                break;
            default:
                throw new IllegalArgumentException("Unknown ClassType: " + classType);
            }
        }
        if (includeStandardClasses && includeImplementedInterfaces && includeAnnotations) {
            includeAllTypes = true;
        }
        final Set<ClassInfo> classInfoSetFiltered = new LinkedHashSet<>(classes.size());
        for (final ClassInfo classInfo : classes) {
            if ((includeAllTypes 
                    || includeStandardClasses && classInfo.isStandardClass()
                    || includeImplementedInterfaces && classInfo.isImplementedInterface()
                    || includeAnnotations && classInfo.isAnnotation()) 
                     Always check blacklist 
                    && !scanSpec.classOrPackageIsBlacklisted(classInfo.name) 
                     Always return whitelisted classes, or external classes if enableExternalClasses is true
                    && (!classInfo.isExternalClass || scanSpec.enableExternalClasses
                     Return external (non-whitelisted) classes if viewing class hierarchy "upwards" 
                            || !strictWhitelist)) {
                 Class passed strict whitelist criteria
                classInfoSetFiltered.add(classInfo);
            }
        }
        return classInfoSetFiltered;
    }
private static Set < ClassInfo > filterClassInfo ( final Collection < ClassInfo > classes , final ScanSpec scanSpec , final boolean strictWhitelist , final ClassType ... classTypes ) { if ( classes == null ) { return Collections . < ClassInfo > emptySet ( ) ; } boolean includeAllTypes = classTypes . length == 0 ; boolean includeStandardClasses = false ; boolean includeImplementedInterfaces = false ; boolean includeAnnotations = false ; for ( final ClassType classType : classTypes ) { switch ( classType ) { case ALL : includeAllTypes = true ; break ; case STANDARD_CLASS : includeStandardClasses = true ; break ; case IMPLEMENTED_INTERFACE : includeImplementedInterfaces = true ; break ; case ANNOTATION : includeAnnotations = true ; break ; case INTERFACE_OR_ANNOTATION : includeImplementedInterfaces = includeAnnotations = true ; break ; default : throw new IllegalArgumentException ( "Unknown ClassType: " + classType ) ; } } if ( includeStandardClasses && includeImplementedInterfaces && includeAnnotations ) { includeAllTypes = true ; } final Set < ClassInfo > classInfoSetFiltered = new LinkedHashSet < > ( classes . size ( ) ) ; for ( final ClassInfo classInfo : classes ) { if ( ( includeAllTypes || includeStandardClasses && classInfo . isStandardClass ( ) || includeImplementedInterfaces && classInfo . isImplementedInterface ( ) || includeAnnotations && classInfo . isAnnotation ( ) ) && ! scanSpec . classOrPackageIsBlacklisted ( classInfo . name ) && ( ! classInfo . isExternalClass || scanSpec . enableExternalClasses || ! strictWhitelist ) ) { classInfoSetFiltered . add ( classInfo ) ; } } return classInfoSetFiltered ; }
Filter classes according to scan spec and class type.
Filter classes according to scan spec and class type .
// Check class type against requested type(s) // // // Always check blacklist  // // Always return whitelisted classes, or external classes if enableExternalClasses is true // Return external (non-whitelisted) classes if viewing class hierarchy "upwards"  // Class passed strict whitelist criteria