diff options
author | jcater <jcater@google.com> | 2018-05-02 08:17:31 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-02 08:18:51 -0700 |
commit | d61a185de8582d29dda7525bb04d8ffc5be3bd11 (patch) | |
tree | 56c94776bceaa11ee55af9fce5a1307e71a22a70 /src/tools/android/java/com | |
parent | 9f2b052d93bfd188687f28fe6771f390d3626936 (diff) |
Clean up code that directly imports nested classes like Builder, Entry, etc.
PiperOrigin-RevId: 195094385
Diffstat (limited to 'src/tools/android/java/com')
9 files changed, 37 insertions, 41 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java index 4fc53e173a..3e030602be 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java @@ -44,7 +44,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import javax.annotation.CheckReturnValue; @@ -121,7 +120,7 @@ public class AttrXmlResourceValue implements XmlResourceValue { } @VisibleForTesting - private static final class BuilderEntry implements Entry<String, ResourceXmlAttrValue> { + private static final class BuilderEntry implements Map.Entry<String, ResourceXmlAttrValue> { private final String name; private final ResourceXmlAttrValue value; @@ -148,7 +147,8 @@ public class AttrXmlResourceValue implements XmlResourceValue { @SafeVarargs @VisibleForTesting - public static XmlResourceValue fromFormatEntries(Entry<String, ResourceXmlAttrValue>... entries) { + public static XmlResourceValue fromFormatEntries( + Map.Entry<String, ResourceXmlAttrValue>... entries) { return of(ImmutableMap.copyOf(Arrays.asList(entries))); } @@ -157,7 +157,8 @@ public class AttrXmlResourceValue implements XmlResourceValue { throws InvalidProtocolBufferException { ImmutableMap.Builder<String, ResourceXmlAttrValue> formats = ImmutableMap.<String, AttrXmlResourceValue.ResourceXmlAttrValue>builder(); - for (Entry<String, SerializeFormat.DataValueXml> entry : proto.getMappedXmlValue().entrySet()) { + for (Map.Entry<String, SerializeFormat.DataValueXml> entry : + proto.getMappedXmlValue().entrySet()) { switch (entry.getKey()) { case FLAGS: formats.put( @@ -413,7 +414,7 @@ public class AttrXmlResourceValue implements XmlResourceValue { xmlValueBuilder .setType(SerializeFormat.DataValueXml.XmlType.ATTR) .putAllNamespace(namespaces.asMap()); - for (Entry<String, ResourceXmlAttrValue> entry : formats.entrySet()) { + for (Map.Entry<String, ResourceXmlAttrValue> entry : formats.entrySet()) { xmlValueBuilder.putMappedXmlValue( entry.getKey(), entry.getValue().appendTo(builder.getXmlValueBuilder())); } @@ -450,7 +451,7 @@ public class AttrXmlResourceValue implements XmlResourceValue { } @VisibleForTesting - public static Entry<String, ResourceXmlAttrValue> asEntryOf(String... keyThenValue) { + public static Map.Entry<String, ResourceXmlAttrValue> asEntryOf(String... keyThenValue) { Preconditions.checkArgument(keyThenValue.length > 0); Preconditions.checkArgument(keyThenValue.length % 2 == 0); ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); @@ -490,7 +491,7 @@ public class AttrXmlResourceValue implements XmlResourceValue { @Override public ValuesResourceDefinition writeTo(ValuesResourceDefinition writer) { - for (Entry<String, String> entry : values.entrySet()) { + for (Map.Entry<String, String> entry : values.entrySet()) { writer = writer .startTag("enum") @@ -528,7 +529,7 @@ public class AttrXmlResourceValue implements XmlResourceValue { } @VisibleForTesting - public static Entry<String, ResourceXmlAttrValue> asEntryOf(String... keyThenValue) { + public static Map.Entry<String, ResourceXmlAttrValue> asEntryOf(String... keyThenValue) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); Preconditions.checkArgument(keyThenValue.length > 0); Preconditions.checkArgument(keyThenValue.length % 2 == 0); @@ -564,7 +565,7 @@ public class AttrXmlResourceValue implements XmlResourceValue { @Override public ValuesResourceDefinition writeTo(ValuesResourceDefinition writer) { - for (Entry<String, String> entry : values.entrySet()) { + for (Map.Entry<String, String> entry : values.entrySet()) { writer = writer .startTag("flag") diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java index c3fb2faefa..7c61feb3ab 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java @@ -22,7 +22,7 @@ import com.google.devtools.build.android.FullyQualifiedName; import com.google.devtools.build.android.XmlResourceValue; import com.google.devtools.build.android.XmlResourceValues; import com.google.devtools.build.android.proto.SerializeFormat; -import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.Builder; +import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml; import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.XmlType; import com.google.protobuf.CodedOutputStream; import java.io.IOException; @@ -96,7 +96,7 @@ public class IdXmlResourceValue implements XmlResourceValue { @Override public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output) throws IOException { - Builder xmlValue = + DataValueXml.Builder xmlValue = SerializeFormat.DataValueXml.newBuilder() .setType(XmlType.ID) .putAllNamespace(namespaces.asMap()); diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java b/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java index 82e8810139..47b3ad5448 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java @@ -23,7 +23,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import java.util.logging.Logger; @@ -39,7 +38,7 @@ import javax.xml.stream.events.StartElement; * resources tag to combining multiple {@link DataResourceXml}s, the Namespaces must be tracked and * kept with each value. */ -public class Namespaces implements Iterable<Entry<String, String>> { +public class Namespaces implements Iterable<Map.Entry<String, String>> { private static final Logger logger = Logger.getLogger(Namespaces.class.getCanonicalName()); private static final Namespaces EMPTY_INSTANCE = new Namespaces(ImmutableMap.<String, String>of()); @@ -128,7 +127,7 @@ public class Namespaces implements Iterable<Entry<String, String>> { // Keeping behavior for backwards compatibility. Map<String, String> combinedNamespaces = new LinkedHashMap<>(); combinedNamespaces.putAll(other.prefixToUri); - for (Entry<String, String> namespace : prefixToUri.entrySet()) { + for (Map.Entry<String, String> namespace : prefixToUri.entrySet()) { String prefix = namespace.getKey(); String namespaceUri = namespace.getValue(); if (combinedNamespaces.containsKey(prefix) @@ -145,7 +144,7 @@ public class Namespaces implements Iterable<Entry<String, String>> { } @Override - public Iterator<Entry<String, String>> iterator() { + public Iterator<Map.Entry<String, String>> iterator() { return prefixToUri.entrySet().iterator(); } diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java index b912cc141e..f26aa0cfb3 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; import javax.annotation.concurrent.Immutable; import javax.xml.namespace.QName; @@ -88,7 +87,7 @@ public class PluralXmlResourceValue implements XmlResourceValue { .addAttributesFrom(attributes.entrySet()) .closeTag(); - for (Entry<String, String> plural : values.entrySet()) { + for (Map.Entry<String, String> plural : values.entrySet()) { definition = definition .startItemTag() diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java index af4184d88a..826a9b17f9 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.EnumMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; /** @@ -73,7 +72,7 @@ public class PublicXmlResourceValue implements XmlResourceValue { @Override public void write( FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) { - for (Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) { + for (Map.Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) { Integer value = entry.getValue().orNull(); mergedDataWriter .define(key) @@ -92,7 +91,7 @@ public class PublicXmlResourceValue implements XmlResourceValue { @Override public void writeResourceToClass(FullyQualifiedName key, AndroidResourceSymbolSink sink) { - for (Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) { + for (Map.Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) { sink.acceptPublicResource(entry.getKey(), key.name(), entry.getValue()); } } @@ -120,7 +119,7 @@ public class PublicXmlResourceValue implements XmlResourceValue { public static XmlResourceValue from(SerializeFormat.DataValueXml proto) { Map<String, String> protoValues = proto.getMappedStringValue(); ImmutableMap.Builder<ResourceType, Optional<Integer>> typeToId = ImmutableMap.builder(); - for (Entry<String, String> entry : protoValues.entrySet()) { + for (Map.Entry<String, String> entry : protoValues.entrySet()) { ResourceType type = ResourceType.getEnum(entry.getKey()); Preconditions.checkNotNull(type); Optional<Integer> id = @@ -142,7 +141,7 @@ public class PublicXmlResourceValue implements XmlResourceValue { public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output) throws IOException { Map<String, String> assignments = Maps.newLinkedHashMapWithExpectedSize(typeToId.size()); - for (Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) { + for (Map.Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) { Optional<Integer> value = entry.getValue(); String stringValue = value.isPresent() ? value.get().toString() : MISSING_ID_VALUE; assignments.put(entry.getKey().toString(), stringValue); @@ -166,7 +165,7 @@ public class PublicXmlResourceValue implements XmlResourceValue { PublicXmlResourceValue other = (PublicXmlResourceValue) value; Map<ResourceType, Optional<Integer>> combined = new EnumMap<>(ResourceType.class); combined.putAll(typeToId); - for (Entry<ResourceType, Optional<Integer>> entry : other.typeToId.entrySet()) { + for (Map.Entry<ResourceType, Optional<Integer>> entry : other.typeToId.entrySet()) { Optional<Integer> existing = combined.get(entry.getKey()); if (existing != null && !existing.equals(entry.getValue())) { throw new IllegalArgumentException( diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java b/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java index a54667ecdb..2b88826898 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java @@ -23,7 +23,7 @@ import com.google.devtools.build.android.FullyQualifiedName; import com.google.devtools.build.android.XmlResourceValue; import com.google.devtools.build.android.XmlResourceValues; import com.google.devtools.build.android.proto.SerializeFormat; -import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.Builder; +import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml; import com.google.errorprone.annotations.Immutable; import java.io.IOException; import java.io.OutputStream; @@ -118,7 +118,7 @@ public class ResourcesAttribute implements XmlResourceValue { throws IOException { SerializeFormat.DataValue.Builder builder = XmlResourceValues.newSerializableDataValueBuilder(sourceId); - Builder xmlValueBuilder = + DataValueXml.Builder xmlValueBuilder = builder .getXmlValueBuilder() .putAllNamespace(namespaces.asMap()) diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java index 98aedd3145..dd28f109e8 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java @@ -29,7 +29,7 @@ import com.google.devtools.build.android.FullyQualifiedName; import com.google.devtools.build.android.XmlResourceValue; import com.google.devtools.build.android.XmlResourceValues; import com.google.devtools.build.android.proto.SerializeFormat; -import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.Builder; +import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml; import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; @@ -298,7 +298,7 @@ public class SimpleXmlResourceValue implements XmlResourceValue { throws IOException { SerializeFormat.DataValue.Builder builder = XmlResourceValues.newSerializableDataValueBuilder(sourceId); - Builder xmlValueBuilder = + DataValueXml.Builder xmlValueBuilder = builder .getXmlValueBuilder() .putAllNamespace(namespaces.asMap()) diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java index 5cd0f6e0a5..4ec0454fc1 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @@ -55,11 +54,11 @@ import javax.annotation.concurrent.Immutable; */ @Immutable public class StyleXmlResourceValue implements XmlResourceValue { - public static final Function<Entry<String, String>, String> ENTRY_TO_ITEM = - new Function<Entry<String, String>, String>() { + public static final Function<Map.Entry<String, String>, String> ENTRY_TO_ITEM = + new Function<Map.Entry<String, String>, String>() { @Nullable @Override - public String apply(Entry<String, String> input) { + public String apply(Map.Entry<String, String> input) { return String.format("<item name='%s'>%s</item>", input.getKey(), input.getValue()); } }; @@ -135,7 +134,7 @@ public class StyleXmlResourceValue implements XmlResourceValue { .setTo(parent) .closeTag() .addCharactersOf("\n"); - for (Entry<String, String> entry : values.entrySet()) { + for (Map.Entry<String, String> entry : values.entrySet()) { definition = definition .startItemTag() diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java index e8df3d93d6..14f7fb1cfd 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java @@ -36,7 +36,6 @@ import java.util.AbstractMap.SimpleEntry; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; import javax.annotation.concurrent.Immutable; @@ -63,20 +62,20 @@ import javax.annotation.concurrent.Immutable; @Immutable public class StyleableXmlResourceValue implements XmlResourceValue { - static final Function<Entry<FullyQualifiedName, Boolean>, SerializeFormat.DataKey> + static final Function<Map.Entry<FullyQualifiedName, Boolean>, SerializeFormat.DataKey> FULLY_QUALIFIED_NAME_TO_DATA_KEY = - new Function<Entry<FullyQualifiedName, Boolean>, SerializeFormat.DataKey>() { + new Function<Map.Entry<FullyQualifiedName, Boolean>, SerializeFormat.DataKey>() { @Override - public SerializeFormat.DataKey apply(Entry<FullyQualifiedName, Boolean> input) { + public SerializeFormat.DataKey apply(Map.Entry<FullyQualifiedName, Boolean> input) { return input.getKey().toSerializedBuilder().setReference(input.getValue()).build(); } }; - static final Function<SerializeFormat.DataKey, Entry<FullyQualifiedName, Boolean>> + static final Function<SerializeFormat.DataKey, Map.Entry<FullyQualifiedName, Boolean>> DATA_KEY_TO_FULLY_QUALIFIED_NAME = - new Function<SerializeFormat.DataKey, Entry<FullyQualifiedName, Boolean>>() { + new Function<SerializeFormat.DataKey, Map.Entry<FullyQualifiedName, Boolean>>() { @Override - public Entry<FullyQualifiedName, Boolean> apply(SerializeFormat.DataKey input) { + public Map.Entry<FullyQualifiedName, Boolean> apply(SerializeFormat.DataKey input) { FullyQualifiedName key = FullyQualifiedName.fromProto(input); return new SimpleEntry<FullyQualifiedName, Boolean>(key, input.getReference()); } @@ -121,7 +120,7 @@ public class StyleableXmlResourceValue implements XmlResourceValue { .startTag("declare-styleable") .named(key) .closeTag(); - for (Entry<FullyQualifiedName, Boolean> entry : attrs.entrySet()) { + for (Map.Entry<FullyQualifiedName, Boolean> entry : attrs.entrySet()) { if (entry.getValue().booleanValue()) { // Move the attr definition to this styleable. definition = definition.adopt(entry.getKey()); @@ -220,7 +219,7 @@ public class StyleableXmlResourceValue implements XmlResourceValue { StyleableXmlResourceValue styleable = (StyleableXmlResourceValue) value; Map<FullyQualifiedName, Boolean> combined = new LinkedHashMap<>(); combined.putAll(attrs); - for (Entry<FullyQualifiedName, Boolean> attr : styleable.attrs.entrySet()) { + for (Map.Entry<FullyQualifiedName, Boolean> attr : styleable.attrs.entrySet()) { if (combined.containsKey(attr.getKey())) { // if either attr is defined in the styleable, the attr will be defined in the styleable. if (attr.getValue() || combined.get(attr.getKey())) { |