All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.checker.index.qual.IndexFor Maven / Gradle / Ivy

Go to download

checker-qual contains annotations (type qualifiers) that a programmer writes to specify Java code for type-checking by the Checker Framework.

The newest version!
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 can be used to index any of the given sequences.
 *
 * 

For example, an expression with type {@code @IndexFor({"a", "b"})} is non-negative and is less * than both {@code a.length} and {@code b.length}. The sequences {@code a} and {@code b} might have * different lengths. * *

The * {@code String.charAt(int)} method is declared as * *

{@code
 * class String {
 *   char charAt(@IndexFor("this") index) { ... }
 * }
 * }
* *

Writing {@code @IndexFor("arr")} is equivalent to writing {@link NonNegative @NonNegative} * {@link LTLengthOf @LTLengthOf("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 @LTLengthOf}. * * @see NonNegative * @see LTLengthOf * @checker_framework.manual #index-checker Index Checker */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) public @interface IndexFor { /** Sequences that the annotated expression is a valid index for. */ String[] value(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy