Debian Codegraph @

src/org/jetbrains/annotations/UnknownNullability.java

raw symbols SCIP
1 /*
2 * Copyright 2000-2021 JetBrains s.r.o.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.jetbrains.annotations;
18
19 import java.lang.annotation.Documented;
20 import java.lang.annotation.ElementType;
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 import java.lang.annotation.Target;
24
25 /**
26 * An element annotated with {@link UnknownNullability} claims that no specific nullability
27 * should be assumed by static analyzer. The unconditional dereference of the annotated value
28 * should not trigger a static analysis warning by default (though static analysis tool may have
29 * an option to perform stricter analysis and issue warnings for {@code @UnknownNullability} as well).
30 * It's mainly useful at method return types to mark methods that may occasionally
31 * return {@code null} but in many cases, user knows that in this particular code path
32 * {@code null} is not possible, so producing a warning would be annoying.
33 * <p>
34 * The {@code UnknownNullability} is the default nullability for unannotated methods, so it's
35 * rarely necessary. An explicit annotation may serve to document the method behavior and also
36 * to override automatic annotation inference result that could be implemented in some static
37 * analysis tools.
38 */
39 @Documented
40 @Retention(RetentionPolicy.CLASS)
41 @Target({ElementType.TYPE_USE})
42 public @interface UnknownNullability {
43 /**
44 * @return textual reason when the annotated value could be null, for documentation purposes.
45 */
46 @NonNls String value() default "";
47 }