Annotation Interface NegativeIndexFor
@Documented
@Retention(RUNTIME)
@Target({TYPE_USE,TYPE_PARAMETER})
@SubtypeOf(SearchIndexFor.class)
public @interface NegativeIndexFor
The annotated expression is between
-1 and -a.length - 1, inclusive, for each
sequence a listed in the annotation.
This type should rarely (if ever) be written by programmers. It is inferred by the
SearchIndexChecker when the result of a call to one of the JDK's binary search methods (like
Arrays.binarySearch) is known to be less than zero. For example, consider the following
code:
int index = Arrays.binarySearch(array, target);
if (index < 0) {
// index's type here is @NegativeIndexFor("array")
index = index * -1;
// now index's type is @IndexFor("array")
}
- See the Checker Framework Manual:
- Index Checker
-
Required Element Summary
Required Elements
-
Element Details
-
value
Sequences for which this value is a "negative index"; that is, the expression is in the range-1to-a.length - 1, inclusive, for each sequenceagiven here.
-