From 64fe70577a5b97ae8074ccb702718fe2c7825cba Mon Sep 17 00:00:00 2001 From: Tobias Thierer Date: Thu, 9 May 2019 16:55:13 +0100 Subject: [PATCH] Flatten Uri.AbstractPart.Representation. This CL drops an unneeded internal class and clarifies what the constant values are used for. Test: Treehugger Change-Id: Ie5e364ec535fba0ae4a57fc9901be77ce10479c4 --- core/java/android/net/Uri.java | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java index 8cf182b41566e..44d977a30d65f 100644 --- a/core/java/android/net/Uri.java +++ b/core/java/android/net/Uri.java @@ -1983,13 +1983,9 @@ public abstract class Uri implements Parcelable, Comparable { */ static abstract class AbstractPart { - /** - * Enum which indicates which representation of a given part we have. - */ - static class Representation { - static final int ENCODED = 1; - static final int DECODED = 2; - } + // Possible values of mCanonicalRepresentation. + static final int REPRESENTATION_ENCODED = 1; + static final int REPRESENTATION_DECODED = 2; volatile String encoded; volatile String decoded; @@ -1997,11 +1993,11 @@ public abstract class Uri implements Parcelable, Comparable { AbstractPart(String encoded, String decoded) { if (encoded != NOT_CACHED) { - this.mCanonicalRepresentation = Representation.ENCODED; + this.mCanonicalRepresentation = REPRESENTATION_ENCODED; this.encoded = encoded; this.decoded = NOT_CACHED; } else if (decoded != NOT_CACHED) { - this.mCanonicalRepresentation = Representation.DECODED; + this.mCanonicalRepresentation = REPRESENTATION_DECODED; this.encoded = NOT_CACHED; this.decoded = decoded; } else { @@ -2019,9 +2015,9 @@ public abstract class Uri implements Parcelable, Comparable { final void writeTo(Parcel parcel) { final String canonicalValue; - if (mCanonicalRepresentation == Representation.ENCODED) { + if (mCanonicalRepresentation == REPRESENTATION_ENCODED) { canonicalValue = encoded; - } else if (mCanonicalRepresentation == Representation.DECODED) { + } else if (mCanonicalRepresentation == REPRESENTATION_DECODED) { canonicalValue = decoded; } else { throw new IllegalArgumentException("Unknown representation: " @@ -2066,9 +2062,9 @@ public abstract class Uri implements Parcelable, Comparable { int representation = parcel.readInt(); String value = parcel.readString(); switch (representation) { - case Representation.ENCODED: + case REPRESENTATION_ENCODED: return fromEncoded(value); - case Representation.DECODED: + case REPRESENTATION_DECODED: return fromDecoded(value); default: throw new IllegalArgumentException("Unknown representation: " @@ -2254,9 +2250,9 @@ public abstract class Uri implements Parcelable, Comparable { static PathPart readFrom(Parcel parcel) { int representation = parcel.readInt(); switch (representation) { - case Representation.ENCODED: + case REPRESENTATION_ENCODED: return fromEncoded(parcel.readString()); - case Representation.DECODED: + case REPRESENTATION_DECODED: return fromDecoded(parcel.readString()); default: throw new IllegalArgumentException("Unknown representation: " + representation);