Package edu.umd.cs.findbugs.ba.npe
Class TypeQualifierNullnessAnnotationDatabase
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.npe.TypeQualifierNullnessAnnotationDatabase
-
- All Implemented Interfaces:
INullnessAnnotationDatabase
public class TypeQualifierNullnessAnnotationDatabase extends java.lang.Object implements INullnessAnnotationDatabase
Implementation of INullnessAnnotationDatabase that is based on JSR-305 type qualifiers.
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanDEBUGTypeQualifierValue<javax.annotation.Nonnull>nonnullTypeQualifierValueprivate static ClassDescriptorPARAMETERS_ARE_NONNULL_BY_DEFAULTprivate static ClassDescriptorRETURN_VALUES_ARE_NONNULL_BY_DEFAULT
-
Constructor Summary
Constructors Constructor Description TypeQualifierNullnessAnnotationDatabase()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDefaultAnnotation(AnnotationDatabase.Target target, java.lang.String c, NullnessAnnotation n)Add a default annotation to the database.voidaddFieldAnnotation(java.lang.String cName, java.lang.String mName, java.lang.String mSig, boolean isStatic, NullnessAnnotation annotation)Add a field annotation to the database.voidaddMethodAnnotation(java.lang.String cName, java.lang.String mName, java.lang.String sig, boolean isStatic, NullnessAnnotation annotation)Add a method annotation to the database.voidaddMethodParameterAnnotation(java.lang.String cName, java.lang.String mName, java.lang.String sig, boolean isStatic, int param, NullnessAnnotation annotation)Add a method parameter annotation to the database.static booleanassertsFirstParameterIsNonnull(XMethod m)NullnessAnnotationgetDirectAnnotation(java.lang.Object o)NullnessAnnotationgetInheritedAnnotation(XMethod m)NullnessAnnotationgetInheritedAnnotation(XMethod m, int parameter)private ClassDescriptorgetNullnessAnnotationClassDescriptor(NullnessAnnotation n)Convert a NullnessAnnotation into the ClassDescriptor of the equivalent JSR-305 nullness type qualifier.NullnessAnnotationgetResolvedAnnotation(java.lang.Object o, boolean getMinimal)Get a resolved NullnessAnnotation on given XMethod, XField, or XMethodParameter.XMethodgetXMethod(java.lang.String cName, java.lang.String mName, java.lang.String sig, boolean isStatic)voidloadAuxiliaryAnnotations()Load "built-in" annotations that might not be evident from the analyzed/referenced code.booleanparameterMustBeNonNull(XMethod m, int param)Determine whether given parameter must be non-null.private NullnessAnnotationtoNullnessAnnotation(TypeQualifierAnnotation tqa)Convert a Nonnull-based TypeQualifierAnnotation into a NullnessAnnotation.
-
-
-
Field Detail
-
DEBUG
private static final boolean DEBUG
-
nonnullTypeQualifierValue
public final TypeQualifierValue<javax.annotation.Nonnull> nonnullTypeQualifierValue
-
PARAMETERS_ARE_NONNULL_BY_DEFAULT
private static final ClassDescriptor PARAMETERS_ARE_NONNULL_BY_DEFAULT
-
RETURN_VALUES_ARE_NONNULL_BY_DEFAULT
private static final ClassDescriptor RETURN_VALUES_ARE_NONNULL_BY_DEFAULT
-
-
Method Detail
-
getResolvedAnnotation
public NullnessAnnotation getResolvedAnnotation(java.lang.Object o, boolean getMinimal)
Description copied from interface:INullnessAnnotationDatabaseGet a resolved NullnessAnnotation on given XMethod, XField, or XMethodParameter.- Specified by:
getResolvedAnnotationin interfaceINullnessAnnotationDatabase- Parameters:
o- an XMethod, XField, or XMethodParametergetMinimal- TODO: what does this mean?- Returns:
- resolved NullnessAnnotation
-
getInheritedAnnotation
@CheckForNull public NullnessAnnotation getInheritedAnnotation(XMethod m, int parameter)
-
getInheritedAnnotation
@CheckForNull public NullnessAnnotation getInheritedAnnotation(XMethod m)
-
getDirectAnnotation
@CheckForNull public NullnessAnnotation getDirectAnnotation(java.lang.Object o)
-
assertsFirstParameterIsNonnull
public static boolean assertsFirstParameterIsNonnull(XMethod m)
-
parameterMustBeNonNull
public boolean parameterMustBeNonNull(XMethod m, int param)
Description copied from interface:INullnessAnnotationDatabaseDetermine whether given parameter must be non-null.- Specified by:
parameterMustBeNonNullin interfaceINullnessAnnotationDatabase- Parameters:
m- a methodparam- parameter (0 == first parameter)- Returns:
- true if the parameter must be non-null, false otherwise
-
getNullnessAnnotationClassDescriptor
private ClassDescriptor getNullnessAnnotationClassDescriptor(NullnessAnnotation n)
Convert a NullnessAnnotation into the ClassDescriptor of the equivalent JSR-305 nullness type qualifier.- Parameters:
n- a NullnessAnnotation- Returns:
- ClassDescriptor of the equivalent JSR-305 nullness type qualifier
-
addDefaultAnnotation
public void addDefaultAnnotation(AnnotationDatabase.Target target, java.lang.String c, NullnessAnnotation n)
Description copied from interface:INullnessAnnotationDatabaseAdd a default annotation to the database.- Specified by:
addDefaultAnnotationin interfaceINullnessAnnotationDatabase- Parameters:
target- one of AnnotationDatabase.METHOD, AnnotationDatabase.FIELD, AnnotationDatabase.PARAMETER, or AnnotationDatabase.ANYc- dotted class name of class default annotation pertains ton- the default NullnessAnnotation
-
addFieldAnnotation
public void addFieldAnnotation(java.lang.String cName, java.lang.String mName, java.lang.String mSig, boolean isStatic, NullnessAnnotation annotation)Description copied from interface:INullnessAnnotationDatabaseAdd a field annotation to the database.- Specified by:
addFieldAnnotationin interfaceINullnessAnnotationDatabase- Parameters:
cName- dotted class namemName- field namemSig- field signatureisStatic- true if field is static, false otherwiseannotation- NullnessAnnotation to add
-
getXMethod
@CheckForNull public XMethod getXMethod(java.lang.String cName, java.lang.String mName, java.lang.String sig, boolean isStatic)
-
addMethodAnnotation
public void addMethodAnnotation(java.lang.String cName, java.lang.String mName, java.lang.String sig, boolean isStatic, NullnessAnnotation annotation)Description copied from interface:INullnessAnnotationDatabaseAdd a method annotation to the database.- Specified by:
addMethodAnnotationin interfaceINullnessAnnotationDatabase- Parameters:
cName- dotted class namemName- method namesig- method signatureisStatic- true if method is static, false otherwiseannotation- NullnessAnnotation to add
-
addMethodParameterAnnotation
public void addMethodParameterAnnotation(@DottedClassName java.lang.String cName, java.lang.String mName, java.lang.String sig, boolean isStatic, int param, NullnessAnnotation annotation)
Description copied from interface:INullnessAnnotationDatabaseAdd a method parameter annotation to the database.- Specified by:
addMethodParameterAnnotationin interfaceINullnessAnnotationDatabase- Parameters:
cName- dotted class namemName- method namesig- method signatureisStatic- true if method is static, false otherwiseparam- parameter (0 == first parameter)annotation- the NullnessAnnotation to add
-
loadAuxiliaryAnnotations
public void loadAuxiliaryAnnotations()
Description copied from interface:INullnessAnnotationDatabaseLoad "built-in" annotations that might not be evident from the analyzed/referenced code.- Specified by:
loadAuxiliaryAnnotationsin interfaceINullnessAnnotationDatabase
-
toNullnessAnnotation
@CheckForNull private NullnessAnnotation toNullnessAnnotation(@CheckForNull TypeQualifierAnnotation tqa)
Convert a Nonnull-based TypeQualifierAnnotation into a NullnessAnnotation.- Parameters:
tqa- Nonnull-based TypeQualifierAnnotation- Returns:
- corresponding NullnessAnnotation
-
-