@SuppressWarnings("unchecked")
	private static <T extends HasJavadoc<?>> void createJavadoc(T model) {
        
		final Javadoc doc = requireNonNull(model).getJavadoc().orElse(Javadoc.of(DEFAULT_TEXT));
		model.set(doc);

		if (model instanceof HasGenerics) {
            // Add @param for each type variable.
			((HasGenerics<?>) model).getGenerics().forEach(g -> 
				g.getLowerBound().ifPresent(t -> addTag(doc, 
					PARAM.setValue("<" + t + ">")
				))
			);
		}

		if (model instanceof ClassOrInterface) {
			// Add @author
			doc.add(AUTHOR.setValue(DEFAULT_NAME));
            
		} else {
			// Add @param for each parameter.
			if (model instanceof HasFields) {
				((HasFields<?>) model).getFields().forEach(f -> 
					addTag(doc, PARAM.setValue(f.getName()))
				);
			}
		}

        if ((model instanceof Method) && (((Method) model).getType() != void.class)) {
            // Add @return to methods.
            addTag(doc, RETURN);
        }
		
		
		if (model instanceof HasConstructors) {
            // Generate javadoc for each constructor.
			((HasConstructors<?>) model).getConstructors()
				.forEach(AutoJavadoc::createJavadoc);
		}

		if (model instanceof HasMethods) {
            // Generate javadoc for each method.
			((HasMethods<?>) model).getMethods()
				.forEach(AutoJavadoc::createJavadoc);
		}
        
        if (model instanceof HasClasses) {
            // Generate javadoc for each subclass.
            ((HasClasses<?>) model).getClasses()
                .forEach(AutoJavadoc::createJavadoc);
        }
	}
Checks if the specified model already has documentation and if not,
generates it. This method will recurse through the model tree to make
sure all children also have documentation.
<p>
If documentation exists but is incomplete, it will be completed without
changing the existing content.

@param <T>    the type of the model to operate on
@param model  the model to add documentation to
common-parent/codegen/src/main/java/com/speedment/common/codegen/controller/AutoJavadoc.java