I am using HAPI FHIR models as dependency in my project.
How can override getItem() method in MyQuestionnaire class to return item[] which contains customField?
// HAPI FHIR model class to represent Questionnaire Resource.
public class Questionnaire {
protected List<QuestionnaireItemComponent> item;
}
// HAPI FHIR model class to represent single item in Questionnaire Resource.
public class QuestionnaireItemComponent {
protected StringType linkId;
protected UriType definition;
}
// this class is to add additional fields to Questionnaire resource
public class MyQuestionnaire extends Questionnaire {
// this throws compilation error.
@Override
public List<MyQuestionnaireItem> getItem() {
if (this.item == null) this.item = new ArrayList<MyQuestionnaireItem>();
return this.item;
}
}
// this class is to add additional fields to item.
public class MyQuestionnaireItem extends QuestionnaireItemComponent {
protected StringType customField;
}