Added in API level 29

PropertyMapper


public interface PropertyMapper

android.view.inspector.PropertyMapper


An interface for mapping the string names of inspectable properties to integer identifiers. This interface is consumed by InspectionCompanion#mapProperties(PropertyMapper). 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.: R.attr.color). For runtime or generated properties properties without attribute IDs, supply Resources#ID_NULL for attributeId.

Summary

Nested classes

class PropertyMapper.PropertyConflictException

Thrown from a map method if a property name is already mapped as different type. 

Public methods

abstract int mapBoolean(String name, int attributeId)

Map a string name to an integer ID for a primitive boolean property.

abstract int mapByte(String name, int attributeId)

Map a string name to an integer ID for a primitive byte property.

abstract int mapChar(String name, int attributeId)

Map a string name to an integer ID for a primitive char property.

abstract int mapColor(String name, int attributeId)

Map a string name to an integer ID for a color property.

abstract int mapDouble(String name, int attributeId)

Map a string name to an integer ID for a primitive double property.

abstract int mapFloat(String name, int attributeId)

Map a string name to an integer ID for a primitive float property.

abstract int mapGravity(String name, int attributeId)

Map a string name to an integer ID for a gravity property.

abstract int mapInt(String name, int attributeId)

Map a string name to an integer ID for a primitive int property.

abstract int mapIntEnum(String name, int attributeId, IntFunction<String> mapping)

Map a string name to an integer ID for an enumeration packed into an int property.

abstract int mapIntFlag(String name, int attributeId, IntFunction<Set<String>> mapping)

Map a string name to an integer ID for a flag set packed into an int property.

abstract int mapLong(String name, int attributeId)

Map a string name to an integer ID for a primitive long property.

abstract int mapObject(String name, int attributeId)

Map a string name to an integer ID for an object property.

abstract int mapResourceId(String name, int attributeId)

Map a string name to an integer ID for an attribute that contains resource IDs.

abstract int mapShort(String name, int attributeId)

Map a string name to an integer ID for a primitive short property.

Public methods

mapBoolean

Added in API level 29
public abstract int mapBoolean (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive boolean property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapByte

Added in API level 29
public abstract int mapByte (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive byte property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapChar

Added in API level 29
public abstract int mapChar (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive char property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapColor

Added in API level 29
public abstract int mapColor (String name, 
                int attributeId)

Map a string name to an integer ID for a color property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

See also:

mapDouble

Added in API level 29
public abstract int mapDouble (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive double property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapFloat

Added in API level 29
public abstract int mapFloat (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive float property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapGravity

Added in API level 29
public abstract int mapGravity (String name, 
                int attributeId)

Map a string name to an integer ID for a gravity property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

See also:

mapInt

Added in API level 29
public abstract int mapInt (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive int property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapIntEnum

Added in API level 29
public abstract int mapIntEnum (String name, 
                int attributeId, 
                IntFunction<String> mapping)

Map a string name to an integer ID for an enumeration packed into an int property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

mapping IntFunction: A mapping from int to String This value cannot be null.

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapIntFlag

Added in API level 29
public abstract int mapIntFlag (String name, 
                int attributeId, 
                IntFunction<Set<String>> mapping)

Map a string name to an integer ID for a flag set packed into an int property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

mapping IntFunction: A mapping from int to a set of strings This value cannot be null.

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapLong

Added in API level 29
public abstract int mapLong (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive long property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapObject

Added in API level 29
public abstract int mapObject (String name, 
                int attributeId)

Map a string name to an integer ID for an object property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapResourceId

Added in API level 29
public abstract int mapResourceId (String name, 
                int attributeId)

Map a string name to an integer ID for an attribute that contains resource IDs.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.

mapShort

Added in API level 29
public abstract int mapShort (String name, 
                int attributeId)

Map a string name to an integer ID for a primitive short property.

Parameters
name String: The name of the property This value cannot be null.

attributeId int: The attribute resource ID of this property, or Resources#ID_NULL

Returns
int An integer ID for the property

Throws
PropertyMapper.PropertyConflictException If the property name is already mapped as another type.