Loading core/java/android/view/inspector/PropertyMapper.java +20 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view.inspector; import android.annotation.AttrRes; import android.annotation.NonNull; import android.content.res.Resources; import java.util.Set; import java.util.function.IntFunction; Loading @@ -30,6 +31,10 @@ import java.util.function.IntFunction; * Mapping properties to IDs enables quick comparisons against shadow copies of inspectable * objects without performing a large number of string comparisons. * * Properties that derive their value from an XML attribute should provide the attribute resource * ID (e.g.: {@code R.attr.color}). For runtime or generated properties properties without * attribute IDs, supply {@link Resources#ID_NULL} for {@code attributeId}. * * @see InspectionCompanion#mapProperties(PropertyMapper) */ public interface PropertyMapper { Loading @@ -37,7 +42,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive boolean property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -47,7 +52,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive byte property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -57,7 +62,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive char property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -67,7 +72,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive double property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -77,7 +82,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive float property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -87,7 +92,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive int property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -97,7 +102,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive long property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -107,7 +112,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive short property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -117,7 +122,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for an object property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -127,7 +132,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a color property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. * @see android.graphics.Color Loading @@ -138,7 +143,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a gravity property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. * @see android.view.Gravity Loading @@ -149,7 +154,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for an enumeration packed into an int property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @param mapping A mapping from int to String * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. Loading @@ -163,7 +168,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for an attribute that contains resource IDs. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -173,7 +178,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a flag set packed into an int property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @param mapping A mapping from int to a set of strings * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. Loading @@ -182,6 +187,7 @@ public interface PropertyMapper { @NonNull String name, @AttrRes int attributeId, @NonNull IntFunction<Set<String>> mapping); /** * Thrown from a map method if a property name is already mapped as different type. */ Loading Loading
core/java/android/view/inspector/PropertyMapper.java +20 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view.inspector; import android.annotation.AttrRes; import android.annotation.NonNull; import android.content.res.Resources; import java.util.Set; import java.util.function.IntFunction; Loading @@ -30,6 +31,10 @@ import java.util.function.IntFunction; * Mapping properties to IDs enables quick comparisons against shadow copies of inspectable * objects without performing a large number of string comparisons. * * Properties that derive their value from an XML attribute should provide the attribute resource * ID (e.g.: {@code R.attr.color}). For runtime or generated properties properties without * attribute IDs, supply {@link Resources#ID_NULL} for {@code attributeId}. * * @see InspectionCompanion#mapProperties(PropertyMapper) */ public interface PropertyMapper { Loading @@ -37,7 +42,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive boolean property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -47,7 +52,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive byte property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -57,7 +62,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive char property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -67,7 +72,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive double property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -77,7 +82,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive float property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -87,7 +92,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive int property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -97,7 +102,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive long property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -107,7 +112,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a primitive short property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -117,7 +122,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for an object property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -127,7 +132,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a color property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. * @see android.graphics.Color Loading @@ -138,7 +143,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a gravity property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. * @see android.view.Gravity Loading @@ -149,7 +154,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for an enumeration packed into an int property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @param mapping A mapping from int to String * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. Loading @@ -163,7 +168,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for an attribute that contains resource IDs. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. */ Loading @@ -173,7 +178,7 @@ public interface PropertyMapper { * Map a string name to an integer ID for a flag set packed into an int property. * * @param name The name of the property * @param attributeId If the property is from an XML attribute, the resource ID of the property * @param attributeId The attribute resource ID of this property, or {@link Resources#ID_NULL} * @param mapping A mapping from int to a set of strings * @return An integer ID for the property * @throws PropertyConflictException If the property name is already mapped as another type. Loading @@ -182,6 +187,7 @@ public interface PropertyMapper { @NonNull String name, @AttrRes int attributeId, @NonNull IntFunction<Set<String>> mapping); /** * Thrown from a map method if a property name is already mapped as different type. */ Loading