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

import com.capgemini.reports.snecmaobjects.ISnecmaObject;
import com.capgemini.reports.snecmaobjects.part.AlternateRevision;

/**
 * Compares two {@link AlternateRevision}'s contents.
 */
public class AlternateComparator extends PartComparator {
    private static final long serialVersionUID = 4589727916093844161L;

    @Override
    public int compare(final ISnecmaObject thisPart, final ISnecmaObject otherPart) {
        int cmp = super.compare(thisPart, otherPart);
        if (cmp != 0) {
            return cmp;
        }
        AlternateRevision thisAlt = (AlternateRevision) thisPart;
        AlternateRevision otherAlt = (AlternateRevision) otherPart;
        cmp = thisAlt.getTypeAlt1().compareTo(otherAlt.getTypeAlt1());
        if (cmp != 0) {
            return cmp;
        }
        cmp = thisAlt.getTypeAlt2().compareTo(otherAlt.getTypeAlt2());
        return cmp;
    }

}
