Debian Codegraph @

src/org/jetbrains/annotations/CheckReturnValue.java

raw symbols SCIP
1 package org.jetbrains.annotations;
2
3 import java.lang.annotation.Documented;
4 import java.lang.annotation.ElementType;
5 import java.lang.annotation.Target;
6
7 /**
8 * Specifies that the method is impure and that its return value must be used.
9 * <p>
10 * For pure methods (annotated with {@code @Contract(pure = true)}),
11 * it's implied that the resulting value is important,
12 * so this annotation would be redundant.
13 * <p>
14 * Some impure methods have side effects and still require the return value to be used.
15 * For example, {@link java.io.InputStream#read(byte[])}
16 * returns the number of bytes actually stored in the byte array.
17 * Without checking the return value, it's impossible to say how many bytes were actually read.
18 * <p>
19 * This annotation should not be used if the return value of the method
20 * provides only <i>additional</i> information.
21 * For example, the main purpose of {@link java.util.Collection#add(Object)}
22 * is to modify the collection, and the return value is only interesting
23 * when adding an element to a set, to see if the set already contained that element before.
24 * <p>
25 * When used on a type, the annotation applies to all methods that do not return {@code void}.
26 * <p>
27 * When used on a package, the annotation applies to all types of that package.
28 *
29 * @see Contract#pure()
30 */
31 @Documented
32 @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE, ElementType.PACKAGE})
33 @ApiStatus.Experimental
34 public @interface CheckReturnValue {
35 }