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

# PropertyReader

*** ** * ** ***

` public interface PropertyReader `   
` `

|---|
| android.view.inspector.PropertyReader |

<br />

*** ** * ** ***

An interface for reading the properties of an inspectable object. `PropertyReader` is defined as an interface that will be called by `https://developer.android.com/reference/android/view/inspector/InspectionCompanion#readProperties(T,%20android.view.inspector.PropertyReader)`. This approach allows a client inspector to read the values of primitive properties without the overhead of instantiating a class to hold the property values for each inspection pass. If an inspectable remains unchanged between reading passes, it should be possible for a `PropertyReader` to avoid new allocations for subsequent reading passes. It has separate methods for all primitive types to avoid autoboxing overhead if a concrete implementation is able to work with primitives. Implementations should be prepared to accept {null} as the value of `https://developer.android.com/reference/android/view/inspector/PropertyReader#readObject(int,%20java.lang.Object)`.
**See also:**

- `https://developer.android.com/reference/android/view/inspector/InspectionCompanion#readProperties(T,%20android.view.inspector.PropertyReader)`

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` Thrown if a client calls a typed read method for a property of a different type. |

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readBoolean(int,%20boolean)(int id, boolean value) ` Read a primitive boolean property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readByte(int,%20byte)(int id, byte value) ` Read a primitive byte property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readChar(int,%20char)(int id, char value) ` Read a primitive character property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readColor(int,%20int)(int id, int value) ` Read a color packed into an int as a property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readColor(int,%20long)(int id, long value) ` Read a color packed into a `ColorLong` as a property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readColor(int,%20android.graphics.Color)(int id, https://developer.android.com/reference/android/graphics/Color value) ` Read a `https://developer.android.com/reference/android/graphics/Color` object as a property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readDouble(int,%20double)(int id, double value) ` Read a read a primitive double property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readFloat(int,%20float)(int id, float value) ` Read a primitive float property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readGravity(int,%20int)(int id, int value) ` Read `https://developer.android.com/reference/android/view/Gravity` packed into an primitive `int`. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readInt(int,%20int)(int id, int value) ` Read a primitive integer property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readIntEnum(int,%20int)(int id, int value) ` Read an enumeration packed into a primitive `int`. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readIntFlag(int,%20int)(int id, int value) ` Read a flag packed into a primitive `int`. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readLong(int,%20long)(int id, long value) ` Read a primitive long property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readObject(int,%20java.lang.Object)(int id, https://developer.android.com/reference/java/lang/Object value) ` Read any object as a property. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readResourceId(int,%20int)(int id, int value) ` Read an integer that contains a resource ID. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/inspector/PropertyReader#readShort(int,%20short)(int id, short value) ` Read a primitive short property. |

## Public methods

### readBoolean

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

```
public abstract void readBoolean (int id, 
                boolean value)
```

Read a primitive boolean property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `boolean`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a `boolean` |

### readByte

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

```
public abstract void readByte (int id, 
                byte value)
```

Read a primitive byte property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `byte`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a `byte` |

### readChar

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

```
public abstract void readChar (int id, 
                char value)
```

Read a primitive character property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `char`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a `char` |

### readColor

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

```
public abstract void readColor (int id, 
                int value)
```

Read a color packed into an int as a property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `int`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a color |

### readColor

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

```
public abstract void readColor (int id, 
                long value)
```

Read a color packed into a `ColorLong` as a property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `long`: Value of the property packed as a `ColorLong`. See the `https://developer.android.com/reference/android/graphics/Color` class for details of the packing. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a color |

### readColor

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

```
public abstract void readColor (int id, 
                Color value)
```

Read a `https://developer.android.com/reference/android/graphics/Color` object as a property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `Color`: Value of the property. This value may be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a color |

### readDouble

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

```
public abstract void readDouble (int id, 
                double value)
```

Read a read a primitive double property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `double`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a `double` |

### readFloat

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

```
public abstract void readFloat (int id, 
                float value)
```

Read a primitive float property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `float`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a `float` |

### readGravity

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

```
public abstract void readGravity (int id, 
                int value)
```

Read `https://developer.android.com/reference/android/view/Gravity` packed into an primitive `int`.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `int`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a gravity property |

### readInt

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

```
public abstract void readInt (int id, 
                int value)
```

Read a primitive integer property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `int`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as an `int` |

### readIntEnum

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

```
public abstract void readIntEnum (int id, 
                int value)
```

Read an enumeration packed into a primitive `int`.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `int`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as an object |

### readIntFlag

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

```
public abstract void readIntFlag (int id, 
                int value)
```

Read a flag packed into a primitive `int`.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `int`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as an object |

### readLong

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

```
public abstract void readLong (int id, 
                long value)
```

Read a primitive long property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `long`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a `long` |

### readObject

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

```
public abstract void readObject (int id, 
                Object value)
```

Read any object as a property. If value is null, the property is marked as empty.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `Object`: Value of the property. This value may be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as an object |

### readResourceId

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

```
public abstract void readResourceId (int id, 
                int value)
```

Read an integer that contains a resource ID.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `int`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a resource ID. |

### readShort

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

```
public abstract void readShort (int id, 
                short value)
```

Read a primitive short property.

<br />

| Parameters ||
|---|---|
| `id` | `int`: Identifier of the property from a `https://developer.android.com/reference/android/view/inspector/PropertyMapper` <br /> |
| `value` | `short`: Value of the property <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/inspector/PropertyReader.PropertyTypeMismatchException` | If the property ID is not mapped as a `short` |