/** * If the checker class is annotated with {@link TypeQualifiers}, return an immutable set with the * same set of classes as the annotation. If the class is not so annotated, return an empty set. * * <p>Subclasses may override this method to return an immutable set of their supported type * qualifiers. * * @return the type qualifiers supported this processor, or an empty set if none * @see TypeQualifiers */ protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { Class<?> classType = this.getClass(); TypeQualifiers typeQualifiersAnnotation = classType.getAnnotation(TypeQualifiers.class); if (typeQualifiersAnnotation == null) return Collections.emptySet(); Set<Class<? extends Annotation>> typeQualifiers = new HashSet<Class<? extends Annotation>>(); for (Class<? extends Annotation> qualifier : typeQualifiersAnnotation.value()) { typeQualifiers.add(qualifier); } return Collections.unmodifiableSet(typeQualifiers); }
/** * Specify 'flow' and 'cast' as supported lint options for all Type checkers. * * <p>WMD: the above comment talks about 'flow', but I don't find a use of it as a lint option. I * added a new key 'flow:inferFromAsserts'. Maybe 'flow' should be used in * BasicAnnotatedTypeFactory with/instead of FLOW_BY_DEFAULT. */ @Override public Set<String> getSupportedLintOptions() { Set<String> lintSet = new HashSet<String>(super.getSupportedLintOptions()); lintSet.add("cast"); lintSet.add("cast:redundant"); lintSet.add("cast:unsafe"); lintSet.add("flow:inferFromAsserts"); // Temporary option to make array subtyping invariant, // which will be the new default soon. lintSet.add("arrays:invariant"); // Temporary option to make casts stricter, in particular when casting // to an array or generic type. This will be the new default soon. lintSet.add("cast:strict"); return Collections.unmodifiableSet(lintSet); }