All Downloads are FREE. Search and download functionalities are using the official Maven repository.

framework.src.org.checkerframework.framework.type.typeannotator.ListTypeAnnotator Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java’s type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.42.0
Show newest version
package org.checkerframework.framework.type.typeannotator;

import org.checkerframework.framework.type.AnnotatedTypeMirror;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * ListTypeAnnotator is a TypeAnnotator that executes a list of {@link TypeAnnotator}
 * for each type visited.
 *
 * Checkers should not extend ListTypeAnnotator; they should instead
 * pass a custom TypeAnnotator to the constructor.
 *
 * @see org.checkerframework.framework.type.typeannotator.ImplicitsTypeAnnotator
 * @see org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator
 */
public final class ListTypeAnnotator extends TypeAnnotator {

    protected final List annotators;

    /**
     * @param annotators the annotators that will be executed for
     *                   each type scanned by this TypeAnnotator.
     *                   They are executed in the order passed in.
     */
    public ListTypeAnnotator(TypeAnnotator... annotators) {
        super(null);
        this.annotators = Collections.unmodifiableList(Arrays.asList(annotators));
    }

    @Override
    protected Void scan(AnnotatedTypeMirror type, Void aVoid) {
        for (TypeAnnotator annotator : annotators) {
            annotator.visit(type, aVoid);
        }

        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy