package com.capgemini.reports.definition.r07report.data.filter;

import com.capgemini.reports.bomlineholder.flattener.line.SnecmaLine;
import com.capgemini.reports.definition.r07report.data.TransformerR07;
import com.capgemini.reports.definition.r07report.data.extractor.lines.ComparableLine;
import lombok.extern.slf4j.Slf4j;

import java.util.Comparator;

/**
 * Provides capabilities for comparing full-depth content between two {@link SnecmaLine}s.
 */
@Slf4j
public class ContentComparator implements Comparator<SnecmaLine<String, TransformerR07>> {
    @Override
    public int compare(final SnecmaLine<String, TransformerR07> line1, final SnecmaLine<String, TransformerR07> line2) {
        if (line1 instanceof ComparableLine && line2 instanceof ComparableLine) {
            return ((ComparableLine) line1).compareLineContent((ComparableLine) line2);
        } else {
            log.warn("A SnecmaLine of unsupported Type was found in the R07 during comparison: {} vs. {}", line1.getClass().getName(), line2
                    .getClass().getName());
            return 1;
        }
    }
}
