InspectionCompanion
public
interface
InspectionCompanion
android.view.inspector.InspectionCompanion<T>
|
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 |
class |
InspectionCompanion.UninitializedPropertyMapException
Thrown by InspectionCompanion.readProperties(java.lang.Object, android.view.inspector.PropertyReader) if called before
InspectionCompanion.mapProperties(android.view.inspector.PropertyMapper) .
|
Public methods
mapProperties
public abstract void mapProperties (PropertyMapper propertyMapper)
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
public abstract void readProperties (T inspectable,
PropertyReader propertyReader)
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 . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# InspectionCompanion\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nInspectionCompanion\n===================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/view/inspector/InspectionCompanion \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nInspectionCompanion\n`\n\n\n`\n\n\n`\n\n|-------------------------------------------------|\n| android.view.inspector.InspectionCompanion\\\u003cT\\\u003e |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn interface for companion objects used to inspect views.\n\nInspection companions only need to handle the properties and node name of the specific class\nthey are defined for, not anything from a parent class. At runtime, the inspector instantiates\none instance of each inspection companion, and handles visiting them in the correct inheritance\norder for each type it inspects.\n\nProperties are read from the top of the type tree to the bottom, so that classes that override\na property in their parent class can overwrite it in the reader. In general, properties will\ncleanly inherit through their getters, and the inspector runtime will read the properties of a\nparent class via the parent's inspection companion, and the child companion will only read\nproperties added or changed since the parent was defined.\n\nSummary\n-------\n\n| ### Nested classes ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` class` | [InspectionCompanion.UninitializedPropertyMapException](/reference/android/view/inspector/InspectionCompanion.UninitializedPropertyMapException) Thrown by [InspectionCompanion.readProperties(java.lang.Object, android.view.inspector.PropertyReader)](/reference/android/view/inspector/InspectionCompanion#readProperties(T,%20android.view.inspector.PropertyReader)) if called before [InspectionCompanion.mapProperties(android.view.inspector.PropertyMapper)](/reference/android/view/inspector/InspectionCompanion#mapProperties(android.view.inspector.PropertyMapper)). |\n\n| ### Public methods ||\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[mapProperties](/reference/android/view/inspector/InspectionCompanion#mapProperties(android.view.inspector.PropertyMapper))`(`[PropertyMapper](/reference/android/view/inspector/PropertyMapper)` propertyMapper) ` Map the string names of the properties this companion knows about to integer IDs. |\n| ` abstract void` | ` `[readProperties](/reference/android/view/inspector/InspectionCompanion#readProperties(T,%20android.view.inspector.PropertyReader))`(T inspectable, `[PropertyReader](/reference/android/view/inspector/PropertyReader)` propertyReader) ` Read the values of an instance of this companion's type into a [PropertyReader](/reference/android/view/inspector/PropertyReader). |\n\nPublic methods\n--------------\n\n### mapProperties\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void mapProperties (PropertyMapper propertyMapper)\n```\n\nMap the string names of the properties this companion knows about to integer IDs.\n\nEach companion is responsible for storing the integer IDs of all its properties. This is the\nonly method that is allowed to modify the stored IDs.\n\nCalling [readProperties(T, android.view.inspector.PropertyReader)](/reference/android/view/inspector/InspectionCompanion#readProperties(T,%20android.view.inspector.PropertyReader)) before calling this results in\nundefined behavior.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `propertyMapper` | `PropertyMapper`: A [PropertyMapper](/reference/android/view/inspector/PropertyMapper) maps string names to IDs. This value cannot be `null`. \u003cbr /\u003e |\n\n### readProperties\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void readProperties (T inspectable, \n PropertyReader propertyReader)\n```\n\nRead the values of an instance of this companion's type into a [PropertyReader](/reference/android/view/inspector/PropertyReader).\n\nThis method needs to return the property IDs stored by\n[mapProperties(android.view.inspector.PropertyMapper)](/reference/android/view/inspector/InspectionCompanion#mapProperties(android.view.inspector.PropertyMapper)). Implementations should track if their properties\nhave been mapped and throw a [UninitializedPropertyMapException](/reference/android/view/inspector/InspectionCompanion.UninitializedPropertyMapException) if this method is\ncalled before {mapProperties}.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------------|-------------------------------------------------------------------------------------------------------------|\n| `inspectable` | `T`: A object of type {T} to read the properties of. This value cannot be `null`. \u003cbr /\u003e |\n| `propertyReader` | `PropertyReader`: An object which receives the property IDs and values. This value cannot be `null`. \u003cbr /\u003e |"]]