Class ValueCheckerUtils
java.lang.Object
org.checkerframework.common.value.ValueCheckerUtils
Utility methods for the Value Checker.
- 
Method SummaryModifier and TypeMethodDescriptiongetExactStringValue(Tree tree, ValueAnnotatedTypeFactory factory) Either returns the exact string value of the given tree according to the Constant Value Checker, or null if the exact value is not known.getExactValue(Tree tree, ValueAnnotatedTypeFactory factory) Either returns the exact value of the given tree according to the Constant Value Checker, or null if the exact value is not known.getExactValue(Element element, ValueAnnotatedTypeFactory factory) Returns the exact value of an annotated element according to the Constant Value Checker, or null if the exact value is not known.getLengthsForStringValues(List<String> values) Gets a list of lengths for a list of string values.getMaxValue(Tree tree, ValueAnnotatedTypeFactory factory) Finds the maximum value in a Value Checker type.static intgetMinLen(Tree tree, ValueAnnotatedTypeFactory valueAnnotatedTypeFactory) Queries the Value Checker to determine if there is a known minimum length for the array represented bytree.getMinLenFromTree(Tree tree, ValueAnnotatedTypeFactory valueATF) Looks up the minlen of a member select tree.getMinValue(Tree tree, ValueAnnotatedTypeFactory factory) Finds the minimum value in a Value Checker type.getPossibleValues(AnnotatedTypeMirror valueType, ValueAnnotatedTypeFactory valueAnnotatedTypeFactory) Returns a range representing the possible integral values represented by the passedAnnotatedTypeMirror.getRangeFromValues(List<? extends Number> values) Get the minimum and maximum of a list and return a range bounded by them.static List<?>getValuesCastedToType(AnnotationMirror anno, TypeMirror castTo, boolean isUnsigned, ValueAnnotatedTypeFactory atypeFactory) Get a list of the values of an annotation, and then cast the values to a given type.static List<?>getValuesCastedToType(AnnotationMirror anno, TypeMirror castTo, ValueAnnotatedTypeFactory atypeFactory) Get a list of the values of an annotation, and then cast the values to a given type.getValuesFromRange(@Nullable Range range, Class<T> expectedType) Get all possible values from the given type and cast them into a boxed primitive type.static JavaExpressionoptimize(JavaExpression je, AnnotatedTypeFactory factory) Optimize the given JavaExpression.
- 
Method Details- 
getValuesCastedToTypepublic static List<?> getValuesCastedToType(AnnotationMirror anno, TypeMirror castTo, ValueAnnotatedTypeFactory atypeFactory) Get a list of the values of an annotation, and then cast the values to a given type.- Parameters:
- anno- the annotation that contains values
- castTo- the type that is casted to
- atypeFactory- the type factory
- Returns:
- a list of values after the casting
 
- 
getValuesCastedToTypepublic static List<?> getValuesCastedToType(AnnotationMirror anno, TypeMirror castTo, boolean isUnsigned, ValueAnnotatedTypeFactory atypeFactory) Get a list of the values of an annotation, and then cast the values to a given type.- Parameters:
- anno- the annotation that contains values
- castTo- the unannotated type that is casted to
- isUnsigned- true if the type being casted to is unsigned
- atypeFactory- the type factory
- Returns:
- a list of values after the casting
 
- 
getRangeFromValuesGet the minimum and maximum of a list and return a range bounded by them.
- 
getValuesFromRangepublic static <T> @Nullable List<T> getValuesFromRange(@Nullable Range range, Class<T> expectedType) Get all possible values from the given type and cast them into a boxed primitive type. Returns null if the list would have length greater thanValueAnnotatedTypeFactory.MAX_VALUES.expectedTypemust be a boxed type, not a primitive type, because primitive types cannot be stored in a list.- Type Parameters:
- T- the type of the values to obtain
- Parameters:
- range- the given range
- expectedType- the expected type
- Returns:
- a list of all the values in the range, or null if there would be more than ValueAnnotatedTypeFactory.MAX_VALUES
 
- 
getLengthsForStringValuesGets a list of lengths for a list of string values.- Parameters:
- values- list of string values
- Returns:
- list of unique lengths of strings in values
 
- 
getPossibleValuespublic static @Nullable Range getPossibleValues(AnnotatedTypeMirror valueType, ValueAnnotatedTypeFactory valueAnnotatedTypeFactory) Returns a range representing the possible integral values represented by the passedAnnotatedTypeMirror. If the passedAnnotatedTypeMirrordoes not contain anIntRangeannotation or anIntValannotation, returns null.
- 
getExactValueEither returns the exact value of the given tree according to the Constant Value Checker, or null if the exact value is not known. This method should only be used by clients who need exactly one value -- such as the LBC's binary operator rules -- and not by those that need to know whether a valueType belongs to a particular qualifier.
- 
getExactValueReturns the exact value of an annotated element according to the Constant Value Checker, or null if the exact value is not known.- Parameters:
- element- the element to get the exact value from
- factory- a ValueAnnotatedTypeFactory used for annotation accessing
- Returns:
- the exact value of the element if it is constant, or null otherwise
 
- 
getExactStringValueEither returns the exact string value of the given tree according to the Constant Value Checker, or null if the exact value is not known. This method should only be used by clients who need exactly one value and not by those that need to know whether a valueType belongs to a particular qualifier.
- 
getMinValueFinds the minimum value in a Value Checker type. If there is no information (such as when the list of possible values is empty or null), returns null. Otherwise, returns the smallest value in the list of possible values.
- 
getMaxValueFinds the maximum value in a Value Checker type. If there is no information (such as when the list of possible values is empty or null), returns null. Otherwise, returns the smallest value in the list of possible values.
- 
getMinLenFromTreeLooks up the minlen of a member select tree. The tree must be an access to a sequence length.
- 
getMinLenQueries the Value Checker to determine if there is a known minimum length for the array represented bytree. If not, returns 0.
- 
optimizeOptimize the given JavaExpression. SeeJavaExpressionOptimizerfor more details.- Parameters:
- je- the expression to optimize
- factory- the annotated type factory
- Returns:
- an optimized version of the argument
 
 
-