framework.src.org.checkerframework.framework.type.typeannotator.ListTypeAnnotator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
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.
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;
}
}