Migrate ActionOwner to @AutoValue.

--
MOS_MIGRATED_REVID=138680612
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
index 82e6797..a7a4aa7 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
@@ -13,11 +13,11 @@
 // limitations under the License.
 package com.google.devtools.build.lib.actions;
 
+import com.google.auto.value.AutoValue;
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
 import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.util.Preconditions;
-
 import javax.annotation.Nullable;
 
 /**
@@ -27,76 +27,59 @@
  * but to avoid storing heavyweight analysis objects in actions, and to avoid coupling between the
  * analysis and actions packages, the RuleConfiguredTarget provides an instance of this class.
  */
+@AutoValue
 @Immutable
-public final class ActionOwner {
+public abstract class ActionOwner {
   /** An action owner for special cases. Usage is strongly discouraged. */
   public static final ActionOwner SYSTEM_ACTION_OWNER =
-      new ActionOwner(null, null, "system", "empty target kind", "system", null);
+      ActionOwner.create(null, null, "system", "empty target kind", "system", null);
 
-  @Nullable private final Label label;
-  @Nullable private final Location location;
-  @Nullable private final String mnemonic;
-  @Nullable private final String targetKind;
-  private final String configurationChecksum;
-  @Nullable private final String additionalProgressInfo;
-
-  public ActionOwner(
+  public static ActionOwner create(
       @Nullable Label label,
       @Nullable Location location,
       @Nullable String mnemonic,
       @Nullable String targetKind,
       String configurationChecksum,
       @Nullable String additionalProgressInfo) {
-    this.label = label;
-    this.location = location;
-    this.mnemonic = mnemonic;
-    this.targetKind = targetKind;
-    this.configurationChecksum = Preconditions.checkNotNull(configurationChecksum);
-    this.additionalProgressInfo = additionalProgressInfo;
+    return new AutoValue_ActionOwner(
+        location,
+        label,
+        mnemonic,
+        Preconditions.checkNotNull(configurationChecksum),
+        targetKind,
+        additionalProgressInfo);
   }
 
   /** Returns the location of this ActionOwner, if any; null otherwise. */
   @Nullable
-  public Location getLocation() {
-    return location;
-  }
+  public abstract Location getLocation();
 
-  /**
-   * Returns the label for this ActionOwner, if any; null otherwise.
-   */
+  /** Returns the label for this ActionOwner, if any; null otherwise. */
   @Nullable
-  public Label getLabel() {
-    return label;
-  }
+  public abstract Label getLabel();
 
   /** Returns the configuration's mnemonic. */
   @Nullable
-  public String getConfigurationMnemonic() {
-    return mnemonic;
-  }
+  public abstract String getConfigurationMnemonic();
 
   /**
    * Returns the short cache key for the configuration of the action owner.
    *
-   * <p>Special action owners that are not targets can return any string here. If the
-   * underlying configuration is null, this should return "null".
+   * <p>Special action owners that are not targets can return any string here. If the underlying
+   * configuration is null, this should return "null".
    */
-  public String getConfigurationChecksum() {
-    return configurationChecksum;
-  }
+  public abstract String getConfigurationChecksum();
 
   /** Returns the target kind (rule class name) for this ActionOwner, if any; null otherwise. */
   @Nullable
-  public String getTargetKind() {
-    return targetKind;
-  }
+  public abstract String getTargetKind();
 
   /**
    * Returns additional information that should be displayed in progress messages, or {@code null}
    * if nothing should be added.
    */
   @Nullable
-  String getAdditionalProgressInfo() {
-    return additionalProgressInfo;
-  }
+  abstract String getAdditionalProgressInfo();
+
+  ActionOwner() {}
 }
diff --git a/src/main/java/com/google/devtools/build/lib/actions/BUILD b/src/main/java/com/google/devtools/build/lib/actions/BUILD
index ca91797..a81c650 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/actions/BUILD
@@ -27,6 +27,7 @@
         "//src/main/java/com/google/devtools/build/skyframe",
         "//src/main/java/com/google/devtools/common/options",
         "//src/main/protobuf:extra_actions_base_java_proto",
+        "//third_party:auto_value",
         "//third_party:guava",
         "//third_party:jsr305",
         "//third_party/protobuf",
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
index ecb2e89..8f186d4 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
@@ -399,7 +399,7 @@
 
   @VisibleForTesting
   public static ActionOwner createActionOwner(Rule rule, BuildConfiguration configuration) {
-    return new ActionOwner(
+    return ActionOwner.create(
         rule.getLabel(),
         rule.getLocation(),
         configuration.getMnemonic(),
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
index fed3d9d..53b83c6 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
@@ -189,7 +189,7 @@
       Root.asSourceRoot(new InMemoryFileSystem().getRootDirectory()));
 
   public static final ActionOwner NULL_ACTION_OWNER =
-      new ActionOwner(
+      ActionOwner.create(
           NULL_LABEL, null, "dummy-configuration-mnemonic", null, "dummy-configuration", null);
 
   public static final ArtifactOwner NULL_ARTIFACT_OWNER =
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
index a0f41d5..5594a32 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
@@ -390,7 +390,7 @@
         "/home/user/bazel/out/abcdef/some/very/very/long/path/for/some/library/directory/foo.jar");
     Label label =
         Label.parseAbsolute("//some/very/very/long/path/for/some/library/directory:libfoo");
-    ActionOwner owner = new ActionOwner(label, null, null, null, "fedcba", null);
+    ActionOwner owner = ActionOwner.create(label, null, null, null, "fedcba", null);
     when(action.getOwner()).thenReturn(owner);
 
     clock.advanceMillis(TimeUnit.SECONDS.toMillis(3));
@@ -517,7 +517,7 @@
     Label labelFooTest = Label.parseAbsolute("//foo/bar:footest");
     ConfiguredTarget targetFooTest = Mockito.mock(ConfiguredTarget.class);
     when(targetFooTest.getLabel()).thenReturn(labelFooTest);
-    ActionOwner fooOwner = new ActionOwner(labelFooTest, null, null, null, "abcdef", null);
+    ActionOwner fooOwner = ActionOwner.create(labelFooTest, null, null, null, "abcdef", null);
 
     Label labelBarTest = Label.parseAbsolute("//baz:bartest");
     ConfiguredTarget targetBarTest = Mockito.mock(ConfiguredTarget.class);
@@ -525,7 +525,7 @@
     TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class);
     when(filteringComplete.getTestTargets())
         .thenReturn(ImmutableSet.of(targetFooTest, targetBarTest));
-    ActionOwner barOwner = new ActionOwner(labelBarTest, null, null, null, "fedcba", null);
+    ActionOwner barOwner = ActionOwner.create(labelBarTest, null, null, null, "fedcba", null);
 
     stateTracker.testFilteringComplete(filteringComplete);