Added null safety annotations.

This commit is contained in:
akwizgran
2016-10-10 13:21:59 +01:00
parent 064b920626
commit 60dee5c4cb
5 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package org.briarproject.api.nullsafety;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierDefault;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* This annotation can be applied to a package or class to indicate that
* the fields, methods and parameters in that element are non-null by default
* unless:
* <ul>
* <li> There is an explicit nullness annotation
* <li> The method overrides a method in a superclass (in which case the
* annotation of the corresponding method or parameter in the superclass
* applies)
* <li> There is a default nullness annotation applied to a more tightly
* nested element.
* </ul>
*/
@Documented
@Nonnull
@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
@Retention(RUNTIME)
public @interface NotNullByDefault {
}