package leigh.eo.sort;

import leigh.eo.EO;
import leigh.mecha.sort.SortCardinality;

import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;

public abstract class EOComparator implements Comparator<EO> {
    private final String key;
    private final Collator collator;
    private final SortCardinality cardinality;

    protected EOComparator(String key, SortCardinality cardinality, Locale locale) {
        this.key = key;
        this.collator = Collator.getInstance(locale);
        this.cardinality = cardinality;
    }

    public String getKey() {
        return key;
    }

    public Collator getCollator() {
        return collator;
    }

    public SortCardinality getCardinality() {
        return cardinality;
    }

    public abstract int compare(EO o1, EO o2);
}
