public ScanResult scan()

in processor/src/main/java/org/apache/commons/weaver/Finder.java [620:685]


    public ScanResult scan(final ScanRequest request) {
        final ScanResult result = new ScanResult();

        if (!request.isConstrained() || request.getSupertypes().contains(Object.class)) {
            for (final Annotated<Class<?>> type : this.withAnnotations().getAllClasses()) {
                result.getWeavable(type.get()).addAnnotations(type.getAnnotations());
            }
        } else {
            for (final WeaveInterest interest : request.getInterests()) {
                final ElementType target = interest.target;
                switch (target) {
                case PACKAGE:
                    for (final Annotated<Package> pkg : this.withAnnotations().findAnnotatedPackages(
                        interest.annotationType)) {
                        result.getWeavable(pkg.get()).addAnnotations(pkg.getAnnotations());
                    }
                    break;
                case TYPE:
                    for (final Annotated<Class<?>> type : this.withAnnotations().findAnnotatedClasses(
                        interest.annotationType)) {
                        result.getWeavable(type.get()).addAnnotations(type.getAnnotations());
                    }
                    break;
                case METHOD:
                    for (final Annotated<Method> method : this.withAnnotations().findAnnotatedMethods(
                        interest.annotationType)) {
                        result.getWeavable(method.get()).addAnnotations(method.getAnnotations());
                    }
                    break;
                case CONSTRUCTOR:
                    for (final Annotated<Constructor<?>> ctor : this.withAnnotations().findAnnotatedConstructors(
                        interest.annotationType)) {
                        result.getWeavable(ctor.get()).addAnnotations(ctor.getAnnotations());
                    }
                    break;
                case FIELD:
                        for (final Annotated<Field> fld : this.withAnnotations()
                            .findAnnotatedFields(interest.annotationType)) {
                            result.getWeavable(fld.get()).addAnnotations(fld.getAnnotations());
                        }
                        break;
                case PARAMETER:
                    for (final Annotated<Parameter<Method>> parameter : this.withAnnotations()
                        .findAnnotatedMethodParameters(interest.annotationType)) {
                            result.getWeavable(parameter.get().getDeclaringExecutable())
                                .getWeavableParameter(parameter.get().getIndex())
                                .addAnnotations(parameter.getAnnotations());
                        }
                    for (final Annotated<Parameter<Constructor<?>>> parameter : this.withAnnotations()
                        .findAnnotatedConstructorParameters(interest.annotationType)) {
                            result.getWeavable(parameter.get().getDeclaringExecutable())
                                .getWeavableParameter(parameter.get().getIndex())
                                .addAnnotations(parameter.getAnnotations());
                        }
                    break;
                default:
                    // should we log something?
                    break;
                }
            }
            request.getSupertypes().stream().map(this.withAnnotations()::findAssignableTypes)
                .flatMap(Collection::stream)
                .forEach(type -> result.getWeavable(type.get()).addAnnotations(type.getAnnotations()));
        }
        return inflater.inflate(result);
    }