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

import com.capgemini.reports.bomlineholder.BOMLineHolder;
import com.capgemini.reports.snecmaobjects.ISnecmaObject;
import com.capgemini.reports.snecmaobjects.part.PartAssembRevision;

/**
 * Compares two {@link PartAssembRevision}'s {@link BOMLineHolder}s.
 */
public class PartAssembComparator extends PartComparator {
    private static final long serialVersionUID = 3276642480323176366L;

    @Override
    public int compare(final ISnecmaObject thisParL, final ISnecmaObject otherPart) {
        int cmp = super.compare(thisParL, otherPart);
        if (cmp != 0) {
            return cmp;
        }
        PartAssembRevision thisPartAssemb = (PartAssembRevision) thisParL;
        PartAssembRevision otherPartAssemb = (PartAssembRevision) otherPart;
        cmp = thisPartAssemb.getTypePartMontage1().compareTo(otherPartAssemb.getTypePartMontage1());
        if (cmp != 0) {
            return cmp;
        }
        cmp = thisPartAssemb.getTypePartMontage2().compareTo(otherPartAssemb.getTypePartMontage2());
        return cmp;
    }
}
