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

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.43.0
Show newest version
package org.checkerframework.framework.type.typeannotator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.checkerframework.framework.type.AnnotatedTypeMirror;

/**
 * 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) { this(Arrays.asList(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(List annotators) { super(null); List annotatorList = new ArrayList<>(); for (TypeAnnotator annotator : annotators) { if (annotator instanceof ListTypeAnnotator) { annotatorList.addAll(((ListTypeAnnotator) annotator).annotators); } else { annotatorList.add(annotator); } } this.annotators = Collections.unmodifiableList(annotatorList); } @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