Rename to RestrictedForEnvironment

API feedback received to turn the annotation more explicit to avoid
confusion.

Bug: 320445933
Test: atest RestrictedForEnvironmentTests
Change-Id: Ia4a3bc4dd96b75eb79e69babbe0aa4a264f41d3c
diff --git a/java/android/annotation/RestrictedFor.java b/java/android/annotation/RestrictedForEnvironment.java
similarity index 88%
rename from java/android/annotation/RestrictedFor.java
rename to java/android/annotation/RestrictedForEnvironment.java
index 94a8895..d471f5e 100644
--- a/java/android/annotation/RestrictedFor.java
+++ b/java/android/annotation/RestrictedForEnvironment.java
@@ -42,8 +42,8 @@
  */
 @Target({TYPE})
 @Retention(RetentionPolicy.RUNTIME)
-@Repeatable(RestrictedFor.Container.class)
-public @interface RestrictedFor {
+@Repeatable(RestrictedForEnvironment.Container.class)
+public @interface RestrictedForEnvironment {
 
     /** List of environments where the entity is restricted. */
     Environment[] environments();
@@ -68,11 +68,12 @@
     }
 
     /**
-     * Container for {@link RestrictedFor} that allows it to be applied repeatedly to types.
+     * Container for {@link RestrictedForEnvironment} that allows it to be applied repeatedly to
+     * types.
      */
     @Retention(RetentionPolicy.RUNTIME)
     @Target(TYPE)
     @interface Container {
-        RestrictedFor[] value();
+        RestrictedForEnvironment[] value();
     }
 }
diff --git a/javatests/android/annotation/RestrictedForTests.java b/javatests/android/annotation/RestrictedForEnvironmentTests.java
similarity index 68%
rename from javatests/android/annotation/RestrictedForTests.java
rename to javatests/android/annotation/RestrictedForEnvironmentTests.java
index a2b932f..9ab45f8 100644
--- a/javatests/android/annotation/RestrictedForTests.java
+++ b/javatests/android/annotation/RestrictedForEnvironmentTests.java
@@ -18,19 +18,20 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.annotation.RestrictedFor.Environment;
+import android.annotation.RestrictedForEnvironment.Environment;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 @RunWith(JUnit4.class)
-public class RestrictedForTests {
+public class RestrictedForEnvironmentTests {
 
     @Test
     public void testAnnotationAvailableInRuntime() throws Exception {
         ClassWithAnnotation clz = new ClassWithAnnotation();
-        RestrictedFor annotation = clz.getClass().getAnnotation(RestrictedFor.class);
+        RestrictedForEnvironment annotation = clz.getClass().getAnnotation(
+                RestrictedForEnvironment.class);
 
         assertThat(annotation).isNotNull();
     }
@@ -38,7 +39,8 @@
     @Test
     public void testAnnotationIsRepeatable() throws Exception {
         ClassWithRepeatedAnnotation clz = new ClassWithRepeatedAnnotation();
-        RestrictedFor[] annotations = clz.getClass().getAnnotationsByType(RestrictedFor.class);
+        RestrictedForEnvironment[] annotations = clz.getClass().getAnnotationsByType(
+                RestrictedForEnvironment.class);
 
         assertThat(annotations).hasLength(2);
     }
@@ -46,7 +48,8 @@
     @Test
     public void testAnnotationParameters() throws Exception {
         ClassWithAnnotation clz = new ClassWithAnnotation();
-        RestrictedFor annotation = clz.getClass().getAnnotation(RestrictedFor.class);
+        RestrictedForEnvironment annotation = clz.getClass().getAnnotation(
+                RestrictedForEnvironment.class);
 
         Environment[] e = annotation.environments();
         assertThat(e).asList().containsExactly(Environment.SDK_SANDBOX);
@@ -57,7 +60,8 @@
     @Test
     public void testAnnotationParameters_environmentToString() throws Exception {
         ClassWithAnnotation clz = new ClassWithAnnotation();
-        RestrictedFor annotation = clz.getClass().getAnnotation(RestrictedFor.class);
+        RestrictedForEnvironment annotation = clz.getClass().getAnnotation(
+                RestrictedForEnvironment.class);
 
         Environment e = annotation.environments()[0];
         assertThat(e).isEqualTo(Environment.SDK_SANDBOX);
@@ -67,22 +71,25 @@
     @Test
     public void testAnnotationParameters_environment_multipleEnvironments() throws Exception {
         ClassWithMultipleEnvironment clz = new ClassWithMultipleEnvironment();
-        RestrictedFor annotation = clz.getClass().getAnnotation(RestrictedFor.class);
+        RestrictedForEnvironment annotation = clz.getClass().getAnnotation(
+                RestrictedForEnvironment.class);
 
         Environment[] e = annotation.environments();
         assertThat(e).asList().containsExactly(Environment.SDK_SANDBOX, Environment.SDK_SANDBOX);
     }
 
-    @RestrictedFor(environments=Environment.SDK_SANDBOX, from=33)
+    @RestrictedForEnvironment(environments=Environment.SDK_SANDBOX, from=33)
     private static class ClassWithAnnotation {
     }
 
-    @RestrictedFor(environments=Environment.SDK_SANDBOX, from=0)
-    @RestrictedFor(environments=Environment.SDK_SANDBOX, from=0)
+    @RestrictedForEnvironment(environments=Environment.SDK_SANDBOX, from=0)
+    @RestrictedForEnvironment(environments=Environment.SDK_SANDBOX, from=0)
     private static class ClassWithRepeatedAnnotation {
     }
 
-    @RestrictedFor(environments={Environment.SDK_SANDBOX, Environment.SDK_SANDBOX}, from=0)
+    @RestrictedForEnvironment(
+        environments={Environment.SDK_SANDBOX, Environment.SDK_SANDBOX},
+        from=0)
     private static class ClassWithMultipleEnvironment {
     }
 }