More cleanups in `GroupedDeps`.

* Replace `numGroups` with `isEmpty` for compressed representations. Callers just want to know if it's empty, and an upcoming change to the compressed representation will make counting the groups O(groups) instead of O(1).
* Rename `listSize` to `numGroups`.
* Rename `create` to `decompress` to indicate it's the inverse of `compress`.
* Use a `CompressionCase` enum for the boilerplate of determining whether the compressed object is empty, a singleton, or multiple deps.
* Check/handle the singleton case (`instanceof SkyKey`) first for consistency.
* Use a helper for casting to `ImmutableList<SkyKey` to limit the unchecked cast to one place.
* Improve preconditions check in `castAsCompressed`.

PiperOrigin-RevId: 513701375
Change-Id: I8b929038e2ec28b5549598f4e4d94fcd44f319d5
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java
index fea4f75..4acb8d1 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TransitiveTraversalFunctionTest.java
@@ -75,7 +75,7 @@
     AtomicBoolean wasOptimizationUsed = new AtomicBoolean(false);
     SkyFunction.Environment mockEnv = Mockito.mock(SkyFunction.Environment.class);
     when(mockEnv.getTemporaryDirectDeps()).thenReturn(groupedDeps);
-    when(mockEnv.getValuesAndExceptions(groupedDeps.get(1)))
+    when(mockEnv.getValuesAndExceptions(groupedDeps.getDepGroup(1)))
         .thenAnswer(
             (invocationOnMock) -> {
               wasOptimizationUsed.set(true);
@@ -104,8 +104,8 @@
     Package pkg = loadPackage(label.getPackageIdentifier());
     TargetAndErrorIfAny targetAndErrorIfAny =
         new TargetAndErrorIfAny(
-            /*packageLoadedSuccessfully=*/ true,
-            /*errorLoadingTarget=*/ null,
+            /* packageLoadedSuccessfully= */ true,
+            /* errorLoadingTarget= */ null,
             pkg.getTarget(label.getName()));
     TransitiveTraversalFunction function =
         new TransitiveTraversalFunction() {
@@ -143,8 +143,8 @@
     Package pkg = loadPackage(label.getPackageIdentifier());
     TargetAndErrorIfAny targetAndErrorIfAny =
         new TargetAndErrorIfAny(
-            /*packageLoadedSuccessfully=*/ true,
-            /*errorLoadingTarget=*/ new NoSuchTargetException("self error is long and last"),
+            /* packageLoadedSuccessfully= */ true,
+            /* errorLoadingTarget= */ new NoSuchTargetException("self error is long and last"),
             pkg.getTarget(label.getName()));
     TransitiveTraversalFunction function =
         new TransitiveTraversalFunction() {
@@ -195,8 +195,8 @@
     Package pkg = loadPackage(label.getPackageIdentifier());
     TargetAndErrorIfAny targetAndErrorIfAny =
         new TargetAndErrorIfAny(
-            /*packageLoadedSuccessfully=*/ true,
-            /*errorLoadingTarget=*/ null,
+            /* packageLoadedSuccessfully= */ true,
+            /* errorLoadingTarget= */ null,
             pkg.getTarget(label.getName()));
     TransitiveTraversalFunction function =
         new TransitiveTraversalFunction() {
@@ -227,7 +227,7 @@
     SkyKey key = PackageValue.key(pkgid);
     EvaluationResult<PackageValue> result =
         SkyframeExecutorTestUtils.evaluate(
-            getSkyframeExecutor(), key, /*keepGoing=*/ false, reporter);
+            getSkyframeExecutor(), key, /* keepGoing= */ false, reporter);
     if (result.hasError()) {
       throw (NoSuchPackageException) result.getError(key).getException();
     }