package poussecafe.doc;

import java.util.Objects;
import java.util.function.Consumer;
import javax.lang.model.element.TypeElement;
import jdk.javadoc.doclet.DocletEnvironment;
import poussecafe.doc.model.boundedcontextdoc.BoundedContextDoc;
import poussecafe.doc.model.boundedcontextdoc.BoundedContextDocId;
import poussecafe.doc.model.boundedcontextdoc.BoundedContextDocRepository;

public abstract class BoundedContextComponentDocCreator implements Consumer<TypeElement> {

    public BoundedContextComponentDocCreator(DocletEnvironment rootDocWrapper) {
        Objects.requireNonNull(rootDocWrapper);
        this.rootDocWrapper = rootDocWrapper;
    }

    private DocletEnvironment rootDocWrapper;

    @Override
    public void accept(TypeElement classDoc) {
        if (isComponentDoc(classDoc)) {
            BoundedContextDoc boundedContextDoc = boundedContextDocRepository
                    .findByPackageNamePrefixing(classDoc.getQualifiedName().toString());
            if (boundedContextDoc != null) {
                Logger.debug("Adding " + componentName() + " with class " + classDoc.getQualifiedName().toString());
                addDoc(boundedContextDoc.attributes().identifier().value(), classDoc);
            } else {
                Logger.warn("Could not add component with missing bounded context: " + classDoc.getQualifiedName().toString());
            }
        }
    }

    protected abstract boolean isComponentDoc(TypeElement classDoc);

    protected abstract String componentName();

    private BoundedContextDocRepository boundedContextDocRepository;

    protected abstract void addDoc(BoundedContextDocId boundedContextDocId,
            TypeElement componentClassDoc);

    protected DocletEnvironment rootDocWrapper() {
        return rootDocWrapper;
    }
}

@@ -1008,24 +1008,132 @@
  != null) %7B%0A
+                BoundedContextDocId boundedContextId = boundedContextDoc.attributes().identifier().value();%0A
             
@@ -1226,32 +1226,63 @@
 ame().toString()
+ + %22 to BC %22 + boundedContextId
 );%0A             
@@ -1309,45 +1309,10 @@
 text
-Doc.attributes().identifier().value()
+Id
 , cl

Add some logging data.