Hi @sindhusr
The resource is first adapted to a `ValueMap` and then injected into the model class. Here's a more detailed explanation of what happens behind the scenes:
When a model class is instantiated, Sling creates a new instance of the class and injects the values of its fields using the `@Inject` annotation. The injection process works as follows:
1. Sling looks up the resource that corresponds to the model instance. This is typically done using the `@Self` annotation, which tells Sling to inject the resource that corresponds to the model instance.
2. Sling adapts the resource to a `ValueMap`. A `ValueMap` is a map-like interface that provides access to the properties of a resource.
3. Sling looks for fields in the model class that are annotated with `@Inject` and have a name that matches a property in the `ValueMap`. For example, if a field is named `propertyName` and there is a property in the `ValueMap` with the same name, Sling will inject the value of that property into the field.
4. If the field is of a different type than the property in the `ValueMap`, Sling will attempt to convert the property to the appropriate type. For example, if the field is of type `int` and the property in the `ValueMap` is a string, Sling will attempt to convert the string to an integer.
5. If there is no property in the `ValueMap` that matches the name of the field, Sling will not inject a value into the field.
6. If the field is not annotated with `@Inject`, Sling will not inject a value into the field.
So, to answer your question, yes, the resource is first adapted to a `ValueMap` and then injected into the model class. This allows the model class to access the properties of the resource using a simple field-based syntax.
Thanks.