InspectionCompanion
interface InspectionCompanion<T : Any!>
android.view.inspector.InspectionCompanion |
An interface for companion objects used to inspect views. Inspection companions only need to handle the properties and node name of the specific class they are defined for, not anything from a parent class. At runtime, the inspector instantiates one instance of each inspection companion, and handles visiting them in the correct inheritance order for each type it inspects. Properties are read from the top of the type tree to the bottom, so that classes that override a property in their parent class can overwrite it in the reader. In general, properties will cleanly inherit through their getters, and the inspector runtime will read the properties of a parent class via the parent's inspection companion, and the child companion will only read properties added or changed since the parent was defined.
Summary
Nested classes | |
---|---|
open |
Thrown by |
Public methods | |
---|---|
abstract Unit |
mapProperties(propertyMapper: PropertyMapper) Map the string names of the properties this companion knows about to integer IDs. |
abstract Unit |
readProperties(inspectable: T, propertyReader: PropertyReader) Read the values of an instance of this companion's type into a |
Public methods
mapProperties
abstract fun mapProperties(propertyMapper: PropertyMapper): Unit
Map the string names of the properties this companion knows about to integer IDs. Each companion is responsible for storing the integer IDs of all its properties. This is the only method that is allowed to modify the stored IDs. Calling readProperties(T,android.view.inspector.PropertyReader)
before calling this results in undefined behavior.
Parameters | |
---|---|
propertyMapper |
PropertyMapper: A PropertyMapper maps string names to IDs. This value cannot be null . |
readProperties
abstract fun readProperties(
inspectable: T,
propertyReader: PropertyReader
): Unit
Read the values of an instance of this companion's type into a PropertyReader
. This method needs to return the property IDs stored by mapProperties(android.view.inspector.PropertyMapper)
. Implementations should track if their properties have been mapped and throw a UninitializedPropertyMapException
if this method is called before {mapProperties}.
Parameters | |
---|---|
inspectable |
T: A object of type {T} to read the properties of. This value cannot be null . |
propertyReader |
PropertyReader: An object which receives the property IDs and values. This value cannot be null . |