Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

RestrictTo

@Target([AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD]) class RestrictTo
androidx.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:
@RestrictScope(TESTS)
    public abstract int getUserId();
  
Example of restricting usage to subclasses:
@RestrictScope(SUBCLASSES)
    public void onDrawForeground(Canvas canvas) { ...
  

Summary

Nested classes

Public constructors
<init>(vararg value: RestrictTo.Scope)

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

Properties
Array<RestrictTo.Scope>

The scope to which usage should be restricted.

Public constructors

<init>

RestrictTo(vararg value: RestrictTo.Scope)

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:
@RestrictScope(TESTS)
    public abstract int getUserId();
  
Example of restricting usage to subclasses:
@RestrictScope(SUBCLASSES)
    public void onDrawForeground(Canvas canvas) { ...
  

Properties

value

val value: Array<RestrictTo.Scope>

The scope to which usage should be restricted.