RestrictTo


  • Cmn
    @MustBeDocumented
    @Retention(value = AnnotationRetention.BINARY)
    @Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.FILE])
    annotation RestrictTo
  • android
    @MustBeDocumented
    @Retention(value = AnnotationRetention.BINARY)
    @Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.FILE])
    @Target(value = [ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.PACKAGE])
    annotation RestrictTo

Denotes that the annotated element should only be accessed from within a specific scope (as defined by Scope).

Example of restricting usage within a library (based on Gradle group ID):

@RestrictTo(GROUP_ID)
public void resetPaddingToInitialValues() { ...

Example of restricting usage to tests:

@RestrictTo(Scope.TESTS)
public abstract int getUserId();

Example of restricting usage to subclasses:

@RestrictTo(Scope.SUBCLASSES)
public void onDrawForeground(Canvas canvas) { ...

Summary

Nested types

Public constructors

RestrictTo(vararg value: RestrictTo.Scope)
Cmn
android
N

Public properties

Array<RestrictTo.Scope>

The scope(s) to which usage should be restricted.

Cmn
android
N

Public constructors

RestrictTo

RestrictTo(vararg value: RestrictTo.Scope)

Public properties

value

val valueArray<RestrictTo.Scope>

The scope(s) to which usage should be restricted.