package org.schoellerfamily.gedbrowser.renderer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.schoellerfamily.gedbrowser.datamodel.Root;
import org.schoellerfamily.gedbrowser.datamodel.Source;

/**
 * @author Dick Schoeller
 */
public class SourcesRenderer extends GedRenderer<Root>
        implements IndexHrefRenderer<Root>, HeaderHrefRenderer<Root>,
        SubmittorsHrefRenderer<Root>, SourcesHrefRenderer<Root> {
    /** Logger. */
    private final Log logger = LogFactory.getLog(getClass());

    /**
     * Constructor.
     *
     * @param root root of data set
     * @param renderingContext the context that we are rendering in
     */
    public SourcesRenderer(final Root root,
            final RenderingContext renderingContext) {
        super(root, new GedRendererFactory(), renderingContext);
    }

    /**
     * @return the collection of source renderers
     */
    public Collection<SourceRenderer> getSources() {
        logger.info("Starting getSources");
        final Collection<Source> sources = getGedObject().getFinder()
                .find(getGedObject(), Source.class);
        final List<SourceRenderer> renderers = new ArrayList<>();
        for (final Source source : sources) {
            renderers.add((SourceRenderer) createGedRenderer(source));
        }
        renderers.sort(new Comparator<SourceRenderer>() {
            /**
             * {@inheritDoc}
             */
            @Override
            public int compare(final SourceRenderer renderer0,
                    final SourceRenderer renderer1) {
                return renderer0.getTitleString()
                        .compareToIgnoreCase(renderer1.getTitleString());
            }
        });
        return renderers;
    }
}

@@ -656,16 +656,542 @@
 ss());%0A%0A
+    /**%0A     * Compares source renderers for sorting by title string.%0A     *%0A     * @author Dick Schoeller%0A     */%0A    private static class SourceRendererComparator%0A            implements Comparator%3CSourceRenderer%3E %7B%0A        /**%0A         * %7B@inheritDoc%7D%0A         */%0A        @Override%0A        public int compare(final SourceRenderer renderer0,%0A                final SourceRenderer renderer1) %7B%0A            return renderer0.getTitleString()%0A                    .compareToIgnoreCase(renderer1.getTitleString());%0A        %7D%0A    %7D%0A%0A
     /**%0A
@@ -2006,27 +2006,16 @@
 ort(new 
-Comparator%3C
 SourceRe
@@ -2024,361 +2024,20 @@
 erer
-%3E() %7B%0A            /**%0A             * %7B@inheritDoc%7D%0A             */%0A            @Override%0A            public int compare(final SourceRenderer renderer0,%0A                    final SourceRenderer renderer1) %7B%0A                return renderer0.getTitleString()%0A                        .compareToIgnoreCase(renderer1.getTitleString());%0A            %7D%0A        %7D
+Comparator()
 );%0A 

reduce a complexity metric