Polishing

- Use Java 8 idioms more consistently.
- Use newer Guava idioms more consistently.
- Apply some IntelliJ IDEA refactoring suggestions.
- Other changes made for readability and/or brevity.

Closes #3462.

PiperOrigin-RevId: 164700946
diff --git a/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java b/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java
index 9d8c13a..a66d93e 100644
--- a/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java
+++ b/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java
@@ -19,7 +19,6 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
 import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.AllowValues;
 import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.DisallowValues;
 import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.FlagPolicy;
@@ -30,9 +29,9 @@
 import com.google.devtools.common.options.OptionsParser.OptionDescription;
 import com.google.devtools.common.options.OptionsParser.OptionValueDescription;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -197,7 +196,7 @@
 
     ImmutableSet<String> commandAndParentCommands =
         command == null
-            ? ImmutableSet.<String>of()
+            ? ImmutableSet.of()
             : CommandNameCache.CommandNameCacheInstance.INSTANCE.get(command);
 
     // Expand all policies to transfer policies on expansion flags to policies on the child flags.
@@ -242,8 +241,7 @@
 
     String expansionFlagName = expansionPolicy.getFlagName();
 
-    ImmutableList.Builder<OptionValueDescription> resultsBuilder =
-        ImmutableList.<OptionValueDescription>builder();
+    ImmutableList.Builder<OptionValueDescription> resultsBuilder = ImmutableList.builder();
     switch (expansionPolicy.getOperationCase()) {
       case SET_VALUE:
         {
@@ -307,7 +305,7 @@
 
     ImmutableList<OptionValueDescription> expansions =
         getExpansionsFromFlagPolicy(originalPolicy, originalOptionDescription, parser);
-    ImmutableList.Builder<OptionValueDescription> subflagBuilder = new ImmutableList.Builder<>();
+    ImmutableList.Builder<OptionValueDescription> subflagBuilder = ImmutableList.builder();
     ImmutableList<OptionValueDescription> subflags =
         subflagBuilder
             .addAll(originalOptionDescription.getImplicitRequirements())
@@ -640,7 +638,7 @@
       // of string comparison. For example, "--foo=0", "--foo=false", "--nofoo", and "-f-"
       // (if the option has an abbreviation) are all equal for boolean flags. Plus converters
       // can be arbitrarily complex.
-      Set<Object> convertedPolicyValues = Sets.newHashSet();
+      Set<Object> convertedPolicyValues = new HashSet<>();
       for (String value : policyValues) {
         Object convertedValue = optionDescription.getConverter().convert(value);
         // Some converters return lists, and if the flag is a repeatable flag, the items in the
@@ -807,7 +805,7 @@
     parser.parseWithSourceFunction(
         OptionPriority.INVOCATION_POLICY,
         INVOCATION_POLICY_SOURCE,
-        Arrays.asList(String.format("--%s=%s", flagName, flagValue)));
+        ImmutableList.of(String.format("--%s=%s", flagName, flagValue)));
   }
 }