org.checkerframework.checker.index.qual.IndexOrHigh Maven / Gradle / Ivy
package org.checkerframework.checker.index.qual;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* An integer that, for each of the given sequences, is either a valid index or is equal to the
* sequence's length.
*
* The
* {@code Arrays.binarySearch} method is declared as
*
*
{@code
* class Arrays {
* int binarySearch(Object[] a, @IndexFor("#1") int fromIndex, @IndexOrHigh("#1") int toIndex, Object key)
* }
* }
*
* Writing {@code @IndexOrHigh("arr")} is equivalent to writing {@link NonNegative @NonNegative}
* {@link LTEqLengthOf @LTEqLengthOf("arr")}, and that is how it is treated internally by the
* checker. Thus, if you write an {@code @IndexFor("arr")} annotation, you might see warnings about
* {@code @NonNegative} or {@code @LTEqLengthOf}.
*
* @see NonNegative
* @see LTLengthOf
* @checker_framework.manual #index-checker Index Checker
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface IndexOrHigh {
/** Sequences that the annotated expression is a valid index for or is equal to the lengeth of. */
String[] value();
}