CostLineSummaryCostingComparator.java

package com.tradecloud.domain.costing.utils;

import com.tradecloud.domain.costing.clean.CostLineSummary;

import java.util.Comparator;

/**
 * First compare by cost line payer type (direct / indirect)
 * Secondly compare by cost group.
 * Thirdly compare by cost line evaluation priority.
 * If there is no evaluation priority, evaluationPriority = null, then it will be sorted to be at the end of the list.
 * <p>
 * This was introduced as a solution to cost lines that rely on other cost lines' cost value.
 */
public class CostLineSummaryCostingComparator implements Comparator<CostLineSummary> {

    @Override
    public int compare(CostLineSummary costLineSummary1, CostLineSummary costLineSummary2) {
        return new CostLineCostingComparator().compare(costLineSummary1.getCostLine(), costLineSummary2.getCostLine());
    }
}