org.checkerframework.checker.index.qual.LengthOf Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java's type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
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 equal to the sequence's length.
*
* This is treated as an {@link IndexOrHigh} annotation internally. This is an implementation
* detail that may change in the future, when this type may be used to implement more precise
* refinements.
*
*
The usual use case for the {@code LengthOf} annotation is in the defintions of custom
* collections. Consider the signature of java.lang.String#length():
*
*
*
* {@code public @LengthOf("this") int length()}
*
*
* @checker_framework.manual #index-checker Index Checker
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
// Has target of METHOD so that it is stored as a declaration annotation and the SameLen Checker can
// read it.
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER, ElementType.METHOD})
public @interface LengthOf {
/** Sequences that the annotated expression is equal to the length of. */
String[] value();
}