In a concrete writer you have to implement the abstract method org.ingomohr.docwriter.docx.AbstractRuleBasedDocxWriter.initRules(). Since this method is called by the no-args-constructor of the AbstractRuleBasedDocxWriter (which is called before the constructor of the concrete writer is called) it's not possible to access parameters passed to the constructor of your concrete writer instance.
Example: (see comment in #initRules)
class MyWriter extends org.ingomohr.docwriter.docx.AbstractRuleBasedDocxWriter {
final Object param;
MyWriter (Object pParam) {
this.param = pParam;
}
@Override
protected List<DocumentRule> initRules() {
// I cannot do something like "new MyRule(param);" because param is not yet set at this time.
return Collections.emptyList();
}
}
Workaround:
Override de.biotronik.biodocwriter.docs.documents.AlmDocumentPlaceholderReplaceWriter.modifyDoc(WordprocessingMLPackage) with something like this:
@Override
protected void modifyDoc(WordprocessingMLPackage pDoc) {
super.modifyDoc(pDoc);
new MyRule(param).apply(pDoc);
}
while the #initRules method returns an empty list as shown in the first snippet.
In a concrete writer you have to implement the abstract method
org.ingomohr.docwriter.docx.AbstractRuleBasedDocxWriter.initRules()
. Since this method is called by the no-args-constructor of theAbstractRuleBasedDocxWriter
(which is called before the constructor of the concrete writer is called) it's not possible to access parameters passed to the constructor of your concrete writer instance.Example: (see comment in
#initRules
)Workaround: Override
de.biotronik.biodocwriter.docs.documents.AlmDocumentPlaceholderReplaceWriter.modifyDoc(WordprocessingMLPackage)
with something like this:while the
#initRules
method returns an empty list as shown in the first snippet.