public class ValueAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.ParameterizedExecutableType
Modifier and Type | Field and Description |
---|---|
static String |
ARRAYLEN_NAME
Fully-qualified class name of
ArrayLen |
static String |
ARRAYLENRANGE_NAME
Fully-qualified class name of
ArrayLenRange |
AnnotationMirror |
BOOLEAN_FALSE
The canonical @
BoolVal (false) annotation. |
AnnotationMirror |
BOOLEAN_TRUE
The canonical @
BoolVal (true) annotation. |
static String |
BOOLVAL_NAME
Fully-qualified class name of
BoolVal |
protected AnnotationMirror |
BOTTOMVAL
The bottom type for this hierarchy.
|
static String |
BOTTOMVAL_NAME
Fully-qualified class name of
BottomVal |
static String |
DOUBLEVAL_NAME
Fully-qualified class name of
DoubleVal |
protected ReflectiveEvaluator |
evaluator
Helper class that evaluates statically executable methods, constructors, and fields.
|
static String |
INTRANGE_FROMGTENEGONE_NAME
Fully-qualified class name of
IntRangeFromGTENegativeOne |
static String |
INTRANGE_FROMNONNEG_NAME
Fully-qualified class name of
IntRangeFromNonNegative |
static String |
INTRANGE_FROMPOS_NAME
Fully-qualified class name of
IntRangeFromPositive |
static String |
INTRANGE_NAME
Fully-qualified class name of
IntRange |
static String |
INTVAL_NAME
Fully-qualified class name of
IntVal |
protected static int |
MAX_VALUES
The maximum number of values allowed in an annotation's array.
|
static String |
MINLEN_NAME
Fully-qualified class name of
MinLen |
AnnotationMirror |
POLY
The canonical @
PolyValue annotation. |
static String |
POLY_NAME
Fully-qualified class name of
PolyValue |
static String |
STRINGVAL_NAME
Fully-qualified class name of
StringVal |
static String |
UNKNOWN_NAME
Fully-qualified class name of
UnknownVal |
protected AnnotationMirror |
UNKNOWNVAL
The top type for this hierarchy.
|
analysis, cfgVisualizer, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, transfer, treeAnnotator, typeAnnotator
artificialTreeToEnclosingElementMap, checker, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState
Constructor and Description |
---|
ValueAnnotatedTypeFactory(BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
AnnotationMirror |
canonicalAnnotation(AnnotationMirror anno)
Returns the canonical annotation for the passed annotation.
|
AnnotationMirror |
convertArrayLenToArrayLenRange(AnnotationMirror arrayLenAnno)
Converts an
@ArrayLen annotation to an @ArrayLenRange annotation. |
AnnotationMirror |
convertIntRangeToIntVal(AnnotationMirror intRangeAnno)
Convert an
@IntRange annotation to an @IntVal annotation, or to UNKNOWNVAL if
the input is too wide to be represented as an @IntVal . |
AnnotationMirror |
convertIntValToIntRange(AnnotationMirror intValAnno)
Converts an
@IntVal annotation to an @IntRange annotation. |
AnnotationMirror |
createArrayLenAnnotation(List<Integer> values)
Returns a
ArrayLen annotation using the values. |
AnnotationMirror |
createArrayLenRangeAnnotation(int from,
int to)
Create an
@ArrayLenRange annotation from the two (inclusive) bounds. |
AnnotationMirror |
createArrayLenRangeAnnotation(Range range)
Create an
@ArrayLenRange annotation from the range. |
AnnotationMirror |
createBooleanAnnotation(List<Boolean> values)
Returns a
BoolVal annotation using the values. |
AnnotationMirror |
createCharAnnotation(List<Character> values)
Returns a
IntVal annotation using the values. |
AnnotationMirror |
createDoubleValAnnotation(List<Double> values)
Returns a
DoubleVal annotation using the values. |
CFTransfer |
createFlowTransferFunction(CFAbstractAnalysis<CFValue,CFStore,CFTransfer> analysis)
Returns the appropriate transfer function that is used for the org.checkerframework.dataflow
analysis.
|
AnnotationMirror |
createIntRangeAnnotation(Range range)
Create an
@IntRange or @IntVal annotation from the range. |
AnnotationMirror |
createIntValAnnotation(List<Long> values)
|
AnnotationMirror |
createNumberAnnotationMirror(List<Number> values)
Returns an annotation that represents the given set of values.
|
protected QualifierHierarchy |
createQualifierHierarchy()
Returns the
QualifierHierarchy to be used by this checker. |
AnnotationMirror |
createStringAnnotation(List<String> values)
Returns a
StringVal annotation using the values. |
protected Set<Class<? extends Annotation>> |
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.
|
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based on the contents of a
tree. |
protected TypeAnnotator |
createTypeAnnotator()
Returns a
DefaultForTypeAnnotator that adds annotations to a type based on the
content of the type itself. |
protected TypeHierarchy |
createTypeHierarchy()
Creates the type hierarchy to be used by this factory.
|
static List<Integer> |
getArrayLength(AnnotationMirror arrayAnno)
Returns the set of possible array lengths as a sorted list with no duplicate values.
|
static Boolean |
getBooleanValue(AnnotationMirror boolAnno)
Returns the single possible boolean value, or null if there is not exactly one possible
value.
|
static List<Boolean> |
getBooleanValues(AnnotationMirror boolAnno)
Returns the set of possible boolean values as a sorted list with no duplicate values.
|
static List<Character> |
getCharValues(AnnotationMirror intAnno)
Returns the set of possible values as a sorted list with no duplicate values.
|
static List<Double> |
getDoubleValues(AnnotationMirror doubleAnno)
Returns the set of possible values as a sorted list with no duplicate values.
|
AnnotatedTypeMirror |
getDummyAssignedTo(ExpressionTree expressionTree)
Returns the annotation type mirror for the type of
expressionTree with default
annotations applied. |
protected Set<Class<? extends Annotation>> |
getFieldInvariantDeclarationAnnotations()
Returns the set of classes of field invariant annotations.
|
FieldInvariants |
getFieldInvariants(TypeElement element)
Returns the field invariants for the given class, as expressed by the user in
@FieldInvariant method annotations. |
long |
getFromValueFromIntRange(AnnotatedTypeMirror atm)
Finds the appropriate value for the
from value of an annotated type mirror containing
an IntRange annotation. |
static List<Long> |
getIntValues(AnnotationMirror intAnno)
Returns the set of possible values as a sorted list with no duplicate values.
|
Integer |
getMaxLenValue(AnnotationMirror annotation)
Used to find the maximum length of an array.
|
Long |
getMinimumIntegralValue(AnnotatedTypeMirror atm)
Returns the smallest possible value that an integral annotation might take on.
|
int |
getMinLenFromString(String sequenceExpression,
Tree tree,
TreePath currentPath)
Returns the minimum length of an array expression or 0 if the min length is unknown.
|
int |
getMinLenValue(AnnotatedTypeMirror atm) |
int |
getMinLenValue(AnnotationMirror annotation)
Used to find the minimum length of an array, which is useful for array bounds checking.
|
static Range |
getRange(AnnotationMirror rangeAnno)
Returns a
Range bounded by the values specified in the given @Range
annotation. |
static List<String> |
getStringValues(AnnotationMirror stringAnno)
Returns the set of possible values as a sorted list with no duplicate values.
|
long |
getToValueFromIntRange(AnnotatedTypeMirror atm)
Finds the appropriate value for the
to value of an annotated type mirror containing
an IntRange annotation. |
boolean |
isIntRange(AnnotationMirror anno)
Returns true if
anno is an IntRange , IntRangeFromPositive , IntRangeFromNonNegative , or IntRangeFromGTENegativeOne . |
boolean |
isIntRange(Set<AnnotationMirror> anmSet) |
AnnotatedTypeFactory.ParameterizedExecutableType |
methodFromUse(ExpressionTree tree,
ExecutableElement methodElt,
AnnotatedTypeMirror receiverType)
Creates array length annotations for the result of the Enum.values() method, which is the
number of possible values of the enum.
|
createFlowAnalysis
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createQualifierDefaults, createQualifierPolymorphism, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpressionString, getAnnotationFromReceiver, getAnnotationMirrorFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getExceptionalExitStore, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getReceiverAndOffsetFromJavaExpressionString, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, methodFromUsePreSubstitution, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyUnboxing, areSameByClass, binaryTreeArgTypes, checkInvalidOptionsInferSignatures, containsSameByClass, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchyWithMultiGraphFactory, createQualifierUpperBounds, createTypeArgumentInference, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, getWidenedAnnotations, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isFromByteCode, isFromStubFile, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeStubsIntoType, negateConstant, parseStubFiles, postProcessClassTree, postTypeVarSubstitution, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, widenToUpperBound
public static final String UNKNOWN_NAME
UnknownVal
public static final String BOTTOMVAL_NAME
BottomVal
public static final String POLY_NAME
PolyValue
public static final String ARRAYLEN_NAME
ArrayLen
public static final String BOOLVAL_NAME
BoolVal
public static final String DOUBLEVAL_NAME
DoubleVal
public static final String INTVAL_NAME
IntVal
public static final String STRINGVAL_NAME
StringVal
public static final String ARRAYLENRANGE_NAME
ArrayLenRange
public static final String INTRANGE_NAME
IntRange
public static final String INTRANGE_FROMGTENEGONE_NAME
IntRangeFromGTENegativeOne
public static final String INTRANGE_FROMNONNEG_NAME
IntRangeFromNonNegative
public static final String INTRANGE_FROMPOS_NAME
IntRangeFromPositive
public static final String MINLEN_NAME
MinLen
protected static final int MAX_VALUES
protected final AnnotationMirror UNKNOWNVAL
protected final AnnotationMirror BOTTOMVAL
public final AnnotationMirror POLY
PolyValue
annotation.public final AnnotationMirror BOOLEAN_TRUE
BoolVal
(true) annotation.public final AnnotationMirror BOOLEAN_FALSE
BoolVal
(false) annotation.protected final ReflectiveEvaluator evaluator
public ValueAnnotatedTypeFactory(BaseTypeChecker checker)
public AnnotationMirror canonicalAnnotation(AnnotationMirror anno)
AnnotatedTypeFactory
A canonical annotation is the internal annotation that will be used by the Checker Framework in the aliased annotation's place.
canonicalAnnotation
in class AnnotatedTypeFactory
anno
- the qualifier to check for an aliasprotected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactory
Subclasses may override this method to return a mutable set of their supported type qualifiers through one of the 5 approaches shown below.
Subclasses should not call this method; they should call AnnotatedTypeFactory.getSupportedTypeQualifiers()
instead.
By default, a checker supports all annotations located in a subdirectory called qual that's located in the same directory as the checker. Note that only annotations defined
with the @Target({ElementType.TYPE_USE})
meta-annotation (and optionally with the
additional value of ElementType.TYPE_PARAMETER
, but no other ElementType
values) are automatically considered as supported annotations.
To support a different set of annotations than those in the qual subdirectory,
or that have other ElementType
values, see examples below.
In total, there are 5 ways to indicate annotations that are supported by a checker:
This is the default behavior. Simply place those annotations within the qual directory.
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers()
by calling AnnotatedTypeFactory.getBundledTypeQualifiers(Class...)
with a varargs parameter list of the other
annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiers(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class);
}
AnnotatedTypeFactory.createSupportedTypeQualifiers()
and return a mutable set of the supported
annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return new HashSet<Class<? extends Annotation>>(
Arrays.asList(A.class, B.class));
}
The set of qualifiers returned by AnnotatedTypeFactory.createSupportedTypeQualifiers()
must be a
fresh, mutable set. The methods AnnotatedTypeFactory.getBundledTypeQualifiers(Class...)
must return
a fresh, mutable set
createSupportedTypeQualifiers
in class AnnotatedTypeFactory
public CFTransfer createFlowTransferFunction(CFAbstractAnalysis<CFValue,CFStore,CFTransfer> analysis)
GenericAnnotatedTypeFactory
This implementation uses the checker naming convention to create the appropriate transfer
function. If no transfer function is found, it returns an instance of CFTransfer
.
Subclasses have to override this method to create the appropriate transfer function if they do not follow the checker naming convention.
createFlowTransferFunction
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
protected QualifierHierarchy createQualifierHierarchy()
AnnotatedTypeFactory
QualifierHierarchy
to be used by this checker.
The implementation builds the type qualifier hierarchy for the AnnotatedTypeFactory.getSupportedTypeQualifiers()
using the meta-annotations found in them. The current
implementation returns an instance of NoElementQualifierHierarchy
.
Subclasses must override this method if their qualifiers have elements; the method must
return an implementation of QualifierHierarchy
, such as ElementQualifierHierarchy
.
createQualifierHierarchy
in class AnnotatedTypeFactory
protected TypeHierarchy createTypeHierarchy()
AnnotatedTypeFactory
Subclasses may override this method to specify new type-checking rules beyond the typical Java subtyping rules.
createTypeHierarchy
in class AnnotatedTypeFactory
protected TypeAnnotator createTypeAnnotator()
GenericAnnotatedTypeFactory
DefaultForTypeAnnotator
that adds annotations to a type based on the
content of the type itself.
Subclass may override this method. The default type annotator is a ListTypeAnnotator
of the following:
IrrelevantTypeAnnotator
: Adds top to types not listed in the RelevantJavaTypes
annotation on the checker.
PropagationTypeAnnotator
: Propagates annotation onto wildcards.
createTypeAnnotator
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
public FieldInvariants getFieldInvariants(TypeElement element)
AnnotatedTypeFactory
@FieldInvariant
method annotations.
Subclasses may implement their own field invariant annotations if @FieldInvariant
is not expressive enough. They must override this method to
properly create AnnotationMirror and also override AnnotatedTypeFactory.getFieldInvariantDeclarationAnnotations()
to return their field invariants.
getFieldInvariants
in class AnnotatedTypeFactory
element
- class for which to get invariantselement
protected Set<Class<? extends Annotation>> getFieldInvariantDeclarationAnnotations()
AnnotatedTypeFactory
getFieldInvariantDeclarationAnnotations
in class AnnotatedTypeFactory
public AnnotatedTypeFactory.ParameterizedExecutableType methodFromUse(ExpressionTree tree, ExecutableElement methodElt, AnnotatedTypeMirror receiverType)
methodFromUse
in class AnnotatedTypeFactory
tree
- either a MethodInvocationTree or a MemberReferenceTreemethodElt
- the element of the referenced methodreceiverType
- the type of the receiverAnnotatedTypeFactory.methodFromUse(MethodInvocationTree)
public long getFromValueFromIntRange(AnnotatedTypeMirror atm)
from
value of an annotated type mirror containing
an IntRange
annotation.atm
- an annotated type mirror that contains an IntRange
annotation.public long getToValueFromIntRange(AnnotatedTypeMirror atm)
to
value of an annotated type mirror containing
an IntRange
annotation.atm
- an annotated type mirror that contains an IntRange
annotation.protected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactory
TreeAnnotator
that adds annotations to a type based on the contents of a
tree.
The default tree annotator is a ListTreeAnnotator
of the following:
PropagationTreeAnnotator
: Propagates annotations from subtrees
LiteralTreeAnnotator
: Adds annotations based on QualifierForLiterals
meta-annotations
DependentTypesTreeAnnotator
: Adapts dependent annotations based on context
Subclasses may override this method to specify additional tree annotators, for example:
new ListTreeAnnotator(super.createTreeAnnotator(), new KeyLookupTreeAnnotator(this));
createTreeAnnotator
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
public AnnotationMirror createIntValAnnotation(List<Long> values)
IntVal
or IntRange
annotation using the values. If values
is null, then UnknownVal is returned; if values
is empty, then bottom is returned. If
the number of values
is greater than MAX_VALUES, return an IntRange
. In other
cases, the values are sorted and duplicates are removed before an IntVal
is created.values
- list of longs; duplicates are allowed and the values may be in any orderpublic AnnotationMirror convertIntRangeToIntVal(AnnotationMirror intRangeAnno)
@IntRange
annotation to an @IntVal
annotation, or to UNKNOWNVAL if
the input is too wide to be represented as an @IntVal
.public AnnotationMirror createDoubleValAnnotation(List<Double> values)
DoubleVal
annotation using the values. If values
is null, then
UnknownVal is returned; if values
is empty, then bottom is returned. The values are
sorted and duplicates are removed before the annotation is created.values
- list of doubles; duplicates are allowed and the values may be in any orderDoubleVal
annotation using the valuespublic AnnotationMirror createStringAnnotation(List<String> values)
StringVal
annotation using the values. If values
is null, then
UnknownVal is returned; if values
is empty, then bottom is returned. The values are
sorted and duplicates are removed before the annotation is created. If values is larger than
the max number of values allowed (10 by default), then an ArrayLen
or an ArrayLenRange
annotation is returned.values
- list of strings; duplicates are allowed and the values may be in any orderStringVal
annotation using the valuespublic AnnotationMirror createArrayLenAnnotation(List<Integer> values)
ArrayLen
annotation using the values. If values
is null, then
UnknownVal is returned; if values
is empty, then bottom is returned. The values are
sorted and duplicates are removed before the annotation is created. If values is larger than
the max number of values allowed (10 by default), then an ArrayLenRange
annotation is
returned.values
- list of integers; duplicates are allowed and the values may be in any orderArrayLen
annotation using the valuespublic AnnotationMirror createBooleanAnnotation(List<Boolean> values)
BoolVal
annotation using the values. If values
is null, then
UnknownVal is returned; if values
is empty, then bottom is returned. The values are
sorted and duplicates are removed before the annotation is created.values
- list of booleans; duplicates are allowed and the values may be in any orderBoolVal
annotation using the valuespublic AnnotationMirror createCharAnnotation(List<Character> values)
IntVal
annotation using the values. If values
is null, then
UnknownVal is returned; if values
is empty, then bottom is returned. The values are
sorted and duplicates are removed before the annotation is created.values
- list of characters; duplicates are allowed and the values may be in any orderIntVal
annotation using the valuespublic AnnotationMirror createNumberAnnotationMirror(List<Number> values)
values
- a homogeneous list: every element of it has the same classpublic AnnotationMirror createIntRangeAnnotation(Range range)
@IntRange
or @IntVal
annotation from the range. May return
BOTTOMVAL or UNKNOWNVAL.public AnnotationMirror createArrayLenRangeAnnotation(int from, int to)
@ArrayLenRange
annotation from the two (inclusive) bounds. Does not return
BOTTOMVAL or UNKNOWNVAL.public AnnotationMirror createArrayLenRangeAnnotation(Range range)
@ArrayLenRange
annotation from the range. May return BOTTOMVAL or
UNKNOWNVAL.public AnnotationMirror convertArrayLenToArrayLenRange(AnnotationMirror arrayLenAnno)
@ArrayLen
annotation to an @ArrayLenRange
annotation.public AnnotationMirror convertIntValToIntRange(AnnotationMirror intValAnno)
@IntVal
annotation to an @IntRange
annotation.public static Range getRange(AnnotationMirror rangeAnno)
Range
bounded by the values specified in the given @Range
annotation. Also returns an appropriate range if an @IntVal
annotation is passed.
Returns null
if the annotation is null or if the annotation is not an IntRange
, IntRangeFromPositive
, IntVal
, or ArrayLenRange
.public static List<Long> getIntValues(AnnotationMirror intAnno)
The method returns a list of Long
but is named getIntValues
because it
supports the @IntVal
annotation.
intAnno
- an @IntVal
annotation, or nullpublic static List<Double> getDoubleValues(AnnotationMirror doubleAnno)
doubleAnno
- a @DoubleVal
annotation, or nullpublic static List<Integer> getArrayLength(AnnotationMirror arrayAnno)
arrayAnno
- an @ArrayLen
annotation, or nullpublic static List<Character> getCharValues(AnnotationMirror intAnno)
intAnno
- an @IntVal
annotation, or nullpublic static Boolean getBooleanValue(AnnotationMirror boolAnno)
boolAnno
- a @BoolVal
annotation, or nullgetBooleanValues
public static List<Boolean> getBooleanValues(AnnotationMirror boolAnno)
boolAnno
- a @BoolVal
annotation, or nullpublic static List<String> getStringValues(AnnotationMirror stringAnno)
stringAnno
- a @StringVal
annotation, or nullpublic boolean isIntRange(Set<AnnotationMirror> anmSet)
public boolean isIntRange(AnnotationMirror anno)
anno
is an IntRange
, IntRangeFromPositive
, IntRangeFromNonNegative
, or IntRangeFromGTENegativeOne
.anno
- annotation mirroranno
is an IntRange
, IntRangeFromPositive
, IntRangeFromNonNegative
, or IntRangeFromGTENegativeOne
public int getMinLenValue(AnnotatedTypeMirror atm)
public Integer getMaxLenValue(AnnotationMirror annotation)
public int getMinLenValue(AnnotationMirror annotation)
Note that this routine handles actual MinLen
annotations, because it is called by
canonicalAnnotation(AnnotationMirror)
, which transforms
MinLen
annotations into ArrayLenRange
annotations.
public Long getMinimumIntegralValue(AnnotatedTypeMirror atm)
AnnotatedTypeMirror
should contain either an @IntRange
annotation or an
@IntVal
annotation. Returns null if it does not.atm
- annotated typeatm
could be the typepublic int getMinLenFromString(String sequenceExpression, Tree tree, TreePath currentPath)
sequenceExpression
- flow expressiontree
- expression tree or variable declarationcurrentPath
- path to local scopepublic AnnotatedTypeMirror getDummyAssignedTo(ExpressionTree expressionTree)
expressionTree
with default
annotations applied.getDummyAssignedTo
in class AnnotatedTypeFactory
expressionTree
- an expression which has no assignment context and for which type
arguments need to be inferrednull
or an annotated type mirror that inferrence should pretend expressionTree
is assigned to