@@ -19,20 +19,21 @@ package androidx.annotation
19
19
import androidx.annotation.RestrictTo.Scope
20
20
21
21
/* *
22
- * Denotes that the annotated element should only be accessed from within a
23
- * specific scope (as defined by [Scope]).
22
+ * Denotes that the annotated element should only be accessed from within a specific scope (as
23
+ * defined by [Scope]).
24
24
*
25
- *
26
- * Example of restricting usage within a library (based on gradle group ID):
25
+ * Example of restricting usage within a library (based on Gradle group ID):
27
26
* ```
28
27
* @RestrictTo(GROUP_ID)
29
28
* public void resetPaddingToInitialValues() { ...
30
29
* ```
30
+ *
31
31
* Example of restricting usage to tests:
32
32
* ```
33
33
* @RestrictTo(Scope.TESTS)
34
34
* public abstract int getUserId();
35
35
* ```
36
+ *
36
37
* Example of restricting usage to subclasses:
37
38
* ```
38
39
* @RestrictTo(Scope.SUBCLASSES)
@@ -53,56 +54,62 @@ import androidx.annotation.RestrictTo.Scope
53
54
)
54
55
public expect annotation class RestrictTo (
55
56
/* *
56
- * The scope to which usage should be restricted.
57
+ * The scope(s) to which usage should be restricted.
57
58
*/
58
59
vararg val value : Scope
59
60
) {
60
61
public enum class Scope {
61
62
/* *
62
- * Restrict usage to code within the same library (e.g. the same
63
- * gradle group ID and artifact ID).
63
+ * Restrict usage to code within the same library (e.g. the same Gradle group ID and
64
+ * artifact ID).
64
65
*/
65
66
LIBRARY ,
66
67
67
68
/* *
68
69
* Restrict usage to code within the same group of libraries.
69
- * This corresponds to the gradle group ID.
70
+ *
71
+ * This corresponds to the Gradle group ID.
70
72
*/
71
73
LIBRARY_GROUP ,
72
74
73
75
/* *
74
- * Restrict usage to code within packages whose groups share
75
- * the same library group prefix up to the last ".", so for
76
- * example libraries foo.bar:lib1 and foo.baz:lib2 share
77
- * the prefix "foo." and so they can use each other's
78
- * apis that are restricted to this scope. Similarly for
79
- * com.foo.bar:lib1 and com.foo.baz:lib2 where they share
80
- * "com.foo.". Library com.bar.qux:lib3 however will not
81
- * be able to use the restricted api because it only
82
- * shares the prefix "com." and not all the way until the
83
- * last ".".
76
+ * Restrict usage to code within packages whose Gradle group IDs share the same prefix up to
77
+ * the last `.` separator.
78
+ *
79
+ * For example, libraries `foo.bar:lib1` and `foo.baz:lib2` share the `foo.` prefix and can
80
+ * therefore use each other's APIs that are restricted to this scope. Similar applies to
81
+ * libraries `com.foo.bar:lib1` and `com.foo.baz:lib2`, which share the `com.foo.` prefix.
82
+ *
83
+ * Library `com.bar.qux:lib3`, however, will not be able to use the restricted API because
84
+ * it only shares the prefix `com.` and not all the way until the last `.` separator.
84
85
*/
85
86
LIBRARY_GROUP_PREFIX ,
86
87
87
88
/* *
88
- * Restrict usage to code within the same group ID (based on gradle
89
- * group ID). This is an alias for [LIBRARY_GROUP_PREFIX].
89
+ * Restrict usage to code within the same group ID (based on Gradle group ID).
90
90
*
91
- * @deprecated Use [LIBRARY_GROUP_PREFIX] instead
91
+ * This is an alias for [LIBRARY_GROUP_PREFIX].
92
92
*/
93
- @Deprecated(" Use LIBRARY_GROUP_PREFIX instead." )
93
+ @Deprecated(
94
+ message = " Use @RestrictTo(LIBRARY_GROUP_PREFIX) instead" ,
95
+ replaceWith = ReplaceWith (
96
+ " LIBRARY_GROUP_PREFIX" ,
97
+ " androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX"
98
+ )
99
+ )
94
100
GROUP_ID ,
95
101
96
102
/* *
97
- * Restrict usage to tests.
103
+ * Restrict usage to test source sets or code annotated with the [TESTS] restriction scope.
104
+ *
105
+ * This is equivalent to `@VisibleForTesting(NONE)`.
98
106
*/
99
107
TESTS ,
100
108
101
109
/* *
102
110
* Restrict usage to subclasses of the enclosing class.
103
111
*
104
- * **Note:** This scope should not be used to annotate
105
- * packages.
112
+ * **Note:** This scope should not be used to annotate packages.
106
113
*/
107
114
SUBCLASSES ,
108
115
}
0 commit comments