# PropertyMapper

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

# PropertyMapper

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/view/inspector/PropertyMapper "View this page in Kotlin")\|Java

`
public


interface
PropertyMapper
`  
`


`

|---------------------------------------|
| android.view.inspector.PropertyMapper |

<br />

*** ** * ** ***

An interface for mapping the string names of inspectable properties to integer identifiers. This interface is consumed by[InspectionCompanion.mapProperties(PropertyMapper)](https://developer.android.com/reference/android/view/inspector/InspectionCompanion#mapProperties(android.view.inspector.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](https://developer.android.com/reference/android/content/res/Resources#ID_NULL)for`attributeId`.  
**See also:**

- [InspectionCompanion.mapProperties(PropertyMapper)](https://developer.android.com/reference/android/view/inspector/InspectionCompanion#mapProperties(android.view.inspector.PropertyMapper))

## Summary

|                                                                                                               ### Nested classes                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) Thrown from a map method if a property name is already mapped as different type. |

|                                                                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                                                                              ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract int` | ` `[mapBoolean](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapBoolean(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a primitive boolean property.                                                                                                                                                                                                                                                                                                                     |
| ` abstract int` | ` `[mapByte](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapByte(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a primitive byte property.                                                                                                                                                                                                                                                                                                                              |
| ` abstract int` | ` `[mapChar](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapChar(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a primitive char property.                                                                                                                                                                                                                                                                                                                              |
| ` abstract int` | ` `[mapColor](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapColor(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a color property.                                                                                                                                                                                                                                                                                                                                     |
| ` abstract int` | ` `[mapDouble](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapDouble(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a primitive double property.                                                                                                                                                                                                                                                                                                                        |
| ` abstract int` | ` `[mapFloat](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapFloat(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a primitive float property.                                                                                                                                                                                                                                                                                                                           |
| ` abstract int` | ` `[mapGravity](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapGravity(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a gravity property.                                                                                                                                                                                                                                                                                                                               |
| ` abstract int` | ` `[mapInt](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a primitive int property.                                                                                                                                                                                                                                                                                                                                 |
| ` abstract int` | ` `[mapIntEnum](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapIntEnum(java.lang.String,%20int,%20java.util.function.IntFunction<java.lang.String>))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId, `[IntFunction](https://developer.android.com/reference/java/util/function/IntFunction)`<`[String](https://developer.android.com/reference/java/lang/String)`> mapping) ` Map a string name to an integer ID for an enumeration packed into an int property.                                                                            |
| ` abstract int` | ` `[mapIntFlag](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapIntFlag(java.lang.String,%20int,%20java.util.function.IntFunction<java.util.Set<java.lang.String>>))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId, `[IntFunction](https://developer.android.com/reference/java/util/function/IntFunction)`<`[Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`>> mapping) ` Map a string name to an integer ID for a flag set packed into an int property. |
| ` abstract int` | ` `[mapLong](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapLong(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for a primitive long property.                                                                                                                                                                                                                                                                                                                              |
| ` abstract int` | ` `[mapObject](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapObject(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for an object property.                                                                                                                                                                                                                                                                                                                                 |
| ` abstract int` | ` `[mapResourceId](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapResourceId(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int attributeId) ` Map a string name to an integer ID for an attribute that contains resource IDs.                                                                                                                                                                                                                                                                                                    |
| ` abstract int` | ` `[mapShort](https://developer.android.com/reference/android/view/inspector/PropertyMapper#mapShort(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/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](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapBoolean (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapByte

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapByte (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapChar

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapChar (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapColor

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapColor (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

**See also:**

- [Color](https://developer.android.com/reference/android/graphics/Color)  

### mapDouble

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapDouble (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapFloat

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapFloat (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapGravity

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapGravity (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

**See also:**

- [Gravity](https://developer.android.com/reference/android/view/Gravity)  

### mapInt

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapInt (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapIntEnum

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |
| `mapping`     | `IntFunction`: A mapping from int to String This value cannot be`null`. <br />                                                                                 |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapIntFlag

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |
| `mapping`     | `IntFunction`: A mapping from int to a set of strings This value cannot be`null`. <br />                                                                       |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapLong

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapLong (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapObject

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapObject (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapResourceId

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapResourceId (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |

### mapShort

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int mapShort (String name, 
                int attributeId)
```

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

<br />

|                                                                                  Parameters                                                                                   ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`        | `String`: The name of the property This value cannot be`null`. <br />                                                                                          |
| `attributeId` | `int`: The attribute resource ID of this property, or[Resources.ID_NULL](https://developer.android.com/reference/android/content/res/Resources#ID_NULL) <br /> |

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | An integer ID for the property <br /> |

|                                                                                                    Throws                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [PropertyMapper.PropertyConflictException](https://developer.android.com/reference/android/view/inspector/PropertyMapper.PropertyConflictException) | If the property name is already mapped as another type. |