Top Description Fields Constructors Methods
org.antlr.v4.runtime.misc

public Class NullUsageProcessor

extends AbstractProcessor
Class Inheritance
Annotations
@SupportedAnnotationTypes:NotNull, Nullable
@SupportedSourceVersion:RELEASE_6
Imports
javax.annotation.processing.AbstractProcessor, .RoundEnvironment, .SupportedAnnotationTypes, .SupportedSourceVersion, javax.lang.model.SourceVersion, javax.lang.model.element.AnnotationMirror, .Element, .ElementKind, .ExecutableElement, .TypeElement, .VariableElement, javax.lang.model.type.NoType, .PrimitiveType, .TypeKind, .TypeMirror, javax.tools.Diagnostic, java.util.ArrayDeque, .ArrayList, .Deque, .HashMap, .HashSet, .List, .Map, .Set

A compile-time validator for correct usage of the NotNull and Nullable annotations.

The validation process checks the following items.

In the future, the validation process may be updated to check the following additional items.

Author
Sam Harwell

Field Summary

Modifier and TypeField and Description
public static final String
private TypeElement
public static final String
private TypeElement
Inherited from javax.annotation.processing.AbstractProcessor:
processingEnv

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private boolean
checkClassNameConstant(String className, Class<?> clazz)

private boolean
private void
checkOverriddenMethod(ExecutableElement overrider, ExecutableElement overridden, Set<Element> errorElements, Set<Element> warnedElements)

private void
private void
checkPrimitiveTypeAnnotations(Set<? extends Element> elements, Diagnostic.Kind kind, TypeElement annotationType)

private void
checkVoidMethodAnnotations(Set<? extends Element> elements, TypeElement annotationType)

private List<? extends TypeMirror>
private AnnotationMirror
getAnnotationMirror(Element element, TypeElement annotationType)

private AnnotationMirror
private AnnotationMirror
private boolean
isNotNull(Element element)

private boolean
public boolean
process(Set<? extends TypeElement>
the annotation interfaces requested to be processed
annotations
,
RoundEnvironment
environment for information about the current and prior round
roundEnv
)

Implements abstract javax.annotation.processing.AbstractProcessor.process.

Implements javax.annotation.processing.Processor.process.

Processes a set of annotation interfaces on root elements originating from the prior round and returns whether or not these annotation interfaces are claimed by this processor.
Inherited from javax.annotation.processing.AbstractProcessor:
getCompletionsgetSupportedAnnotationTypesgetSupportedOptionsgetSupportedSourceVersioninitisInitialized

Field Detail

NotNullClassNameback to summary
public static final String NotNullClassName
notNullTypeback to summary
private TypeElement notNullType
NullableClassNameback to summary
public static final String NullableClassName
nullableTypeback to summary
private TypeElement nullableType

Constructor Detail

NullUsageProcessorback to summary
public NullUsageProcessor()

Method Detail

addElementsToNamedMethodMapback to summary
private void addElementsToNamedMethodMap(Set<? extends Element> elements, Map<String, Map<ExecutableElement, List<Element>>> namedMethodMap)
checkClassNameConstantback to summary
private boolean checkClassNameConstant(String className, Class<?> clazz)
checkClassNameConstantsback to summary
private boolean checkClassNameConstants()
checkOverriddenMethodback to summary
private void checkOverriddenMethod(ExecutableElement overrider, ExecutableElement overridden, Set<Element> errorElements, Set<Element> warnedElements)
checkOverriddenMethodsback to summary
private void checkOverriddenMethods(ExecutableElement method)
checkPrimitiveTypeAnnotationsback to summary
private void checkPrimitiveTypeAnnotations(Set<? extends Element> elements, Diagnostic.Kind kind, TypeElement annotationType)
checkVoidMethodAnnotationsback to summary
private void checkVoidMethodAnnotations(Set<? extends Element> elements, TypeElement annotationType)
getAllSupertypesback to summary
private List<? extends TypeMirror> getAllSupertypes(TypeMirror type)
getAnnotationMirrorback to summary
private AnnotationMirror getAnnotationMirror(Element element, TypeElement annotationType)
getNotNullAnnotationMirrorback to summary
private AnnotationMirror getNotNullAnnotationMirror(Element element)
getNullableAnnotationMirrorback to summary
private AnnotationMirror getNullableAnnotationMirror(Element element)
isNotNullback to summary
private boolean isNotNull(Element element)
isNullableback to summary
private boolean isNullable(Element element)
processback to summary
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)

Implements abstract javax.annotation.processing.AbstractProcessor.process.

Implements javax.annotation.processing.Processor.process.

Doc from javax.annotation.processing.AbstractProcessor.process.

Processes a set of annotation interfaces on root elements originating from the prior round and returns whether or not these annotation interfaces are claimed by this processor. If true is returned, the annotation interfaces are claimed and subsequent processors will not be asked to process them; if false is returned, the annotation interfaces are unclaimed and subsequent processors may be asked to process them. A processor may always return the same boolean value or may vary the result based on its own chosen criteria.

The input set will be empty if the processor supports "*" and the root elements have no annotations. A Processor must gracefully handle an empty set of annotations.

Parameters
annotations:Set<? extends TypeElement>

Doc from javax.annotation.processing.Processor.process.

the annotation interfaces requested to be processed

roundEnv:RoundEnvironment

Doc from javax.annotation.processing.Processor.process.

environment for information about the current and prior round

Returns:boolean

Doc from javax.annotation.processing.Processor.process.

whether or not the set of annotation interfaces are claimed by this processor

Annotations
@Override