# RestrictTo.Scope

Artifact: [androidx.annotation:annotation](https://developer.android.com/jetpack/androidx/releases/annotation) [View Source](https://cs.android.com/search?q=file:androidx/annotation/RestrictTo.+class:androidx.annotation.RestrictTo.Scope) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.0.0)

*** ** * ** ***


```
public enum RestrictTo.Scope extends Enum<@NonNull RestrictTo.Scope>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [kotlin.Enum](https://developer.android.com/reference/java/lang/Enum.html)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) [RestrictTo.Scope](https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope)\> ||
|   | ↳ | [androidx.annotation.RestrictTo.Scope](https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope) |

*** ** * ** ***

## Summary

| ### Enum Values |
|---|---|
| `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#GROUP_ID` | **This enum value is deprecated.** Use @RestrictTo(LIBRARY_GROUP_PREFIX) instead |
| `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#LIBRARY` | Restrict usage to code within the same library (e.g. the same Gradle group ID and artifact ID). |
| `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#LIBRARY_GROUP` | Restrict usage to code within the same group of libraries. |
| `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#LIBRARY_GROUP_PREFIX` | Restrict usage to code within packages whose Gradle group IDs share the same prefix up to the last `.` |
| `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#SUBCLASSES` | Restrict usage to subclasses of the enclosing class. |
| `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#TESTS` | Restrict usage to test source sets or code annotated with the `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#TESTS` restriction scope. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope>` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#getEntries()()` Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope>` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#getEntries()()` Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope>` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#getEntries()()` Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#valueOf(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Returns the enum constant of this type with the specified name. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#valueOf(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Returns the enum constant of this type with the specified name. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#valueOf(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Returns the enum constant of this type with the specified name. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull RestrictTo.Scope[]` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull RestrictTo.Scope[]` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull RestrictTo.Scope[]` | `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |

## Enum Values

### GROUP_ID

```
RestrictTo.Scope RestrictTo.Scope.GROUP_ID
```

Restrict usage to code within the same group ID (based on Gradle group ID).

This is an alias for `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#LIBRARY_GROUP_PREFIX`.

### LIBRARY

```
RestrictTo.Scope RestrictTo.Scope.LIBRARY
```

Restrict usage to code within the same library (e.g. the same Gradle group ID and artifact ID).

### LIBRARY_GROUP

```
RestrictTo.Scope RestrictTo.Scope.LIBRARY_GROUP
```

Restrict usage to code within the same group of libraries.

This corresponds to the Gradle group ID.

### LIBRARY_GROUP_PREFIX

```
RestrictTo.Scope RestrictTo.Scope.LIBRARY_GROUP_PREFIX
```

Restrict usage to code within packages whose Gradle group IDs share the same prefix up to the last `.` separator.

For example, libraries `foo.bar:lib1` and `foo.baz:lib2` share the `foo.` prefix and can therefore use each other's APIs that are restricted to this scope. Similar applies to libraries `com.foo.bar:lib1` and `com.foo.baz:lib2`, which share the `com.foo.` prefix.

Library `com.bar.qux:lib3`, however, will not be able to use the restricted API because it only shares the prefix `com.` and not all the way until the last `.` separator.

### SUBCLASSES

```
RestrictTo.Scope RestrictTo.Scope.SUBCLASSES
```

Restrict usage to subclasses of the enclosing class.

**Note:** This scope should not be used to annotate packages.

### TESTS

```
RestrictTo.Scope RestrictTo.Scope.TESTS
```

Restrict usage to test source sets or code annotated with the `https://developer.android.com/reference/androidx/annotation/RestrictTo.Scope#TESTS` restriction scope.

This is equivalent to `@VisibleForTesting(NONE)`.

## Public methods

### getEntries

```
public final @NonNull EnumEntries<@NonNull RestrictTo.Scope> getEntries()
```

Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared.

### getEntries

```
public final @NonNull EnumEntries<@NonNull RestrictTo.Scope> getEntries()
```

Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared.

### getEntries

```
public final @NonNull EnumEntries<@NonNull RestrictTo.Scope> getEntries()
```

Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared.

### valueOf

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.0.0)

```
public static final @NonNull RestrictTo.Scope valueOf(@NonNull String value)
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if this enum type has no constant with the specified name |

### valueOf

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.0.0)

```
public static final @NonNull RestrictTo.Scope valueOf(@NonNull String value)
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if this enum type has no constant with the specified name |

### valueOf

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.0.0)

```
public static final @NonNull RestrictTo.Scope valueOf(@NonNull String value)
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if this enum type has no constant with the specified name |

### values

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.0.0)

```
public static final @NonNull RestrictTo.Scope[] values()
```

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.

The function returns a new instance of the array on every call. The array could be mutated, so working with it may also require defensive copying. Consider using `entries` property as a more efficient alternative returning an immutable list of enum entries.

### values

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.0.0)

```
public static final @NonNull RestrictTo.Scope[] values()
```

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.

The function returns a new instance of the array on every call. The array could be mutated, so working with it may also require defensive copying. Consider using `entries` property as a more efficient alternative returning an immutable list of enum entries.

### values

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.0.0)

```
public static final @NonNull RestrictTo.Scope[] values()
```

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.

The function returns a new instance of the array on every call. The array could be mutated, so working with it may also require defensive copying. Consider using `entries` property as a more efficient alternative returning an immutable list of enum entries.