@Model(adaptables = "Resource.class", defaultInjectionStrategy = DefaultInjectionStrategy.Optional)
public class Xyz {
@getter
@inject
private String A;
@Self
Private ABC bclass;
}
@Model(adaptables = "Resource.class", defaultInjectionStrategy = DefaultInjectionStrategy.Optional)
public class ABC {
@getter
@inject
private String C;
@getter
@inject
private String D;
}
Using the @Deleted Account annotation, you will be able to achieve this.
@Deleted Account Annotation - this annotation injects the adaptable object itself. If the @Deleted Account annotation is present it is tried to adapt the adaptable to the field type.
Reference Details: https://taradevko.com/aem/sling-models-self-annotation/
Hope this helps!
Thanks