package data;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Objects;

/*
Created for when words are sorted by multiple keys, i.e. not just lemmas but lemmas and msd simultaneously.
*/
public interface MultipleHMKeys {
    String getK1();
    default String getK2(){ return null; }
    default String getK3(){ return null; }
    default String getK4(){ return null; }
    default String getK5(){ return null; }

    default ArrayList<MultipleHMKeys> getSplittedMultipleHMKeys(){ return null; }

    default String getMsd(Filter filter) {
        String msd = "";
        if (filter.getCalculateFor().equals(CalculateFor.MORPHOSYNTACTIC_SPECS)){
            msd = getK1();
        } else if (filter.getMultipleKeys().contains(CalculateFor.MORPHOSYNTACTIC_SPECS)) {
            int i = 0;
            for (CalculateFor otherKey : filter.getMultipleKeys()) {
                switch (i) {
                    case 0:
                        if (otherKey.equals(CalculateFor.MORPHOSYNTACTIC_SPECS)) {
                            msd = getK2();
                        }
                        break;
                    case 1:
                        if (otherKey.equals(CalculateFor.MORPHOSYNTACTIC_SPECS)) {
                            msd = getK3();
                        }
                        break;
                    case 2:
                        if (otherKey.equals(CalculateFor.MORPHOSYNTACTIC_SPECS)) {
                            msd = getK4();
                        }
                        break;
                    case 3:
                        if (otherKey.equals(CalculateFor.MORPHOSYNTACTIC_SPECS)) {
                            msd = getK5();
                        }
                        break;
                }

                i++;
            }
        }
        return msd;
    }

    @Override
    int hashCode();

    @Override
    boolean equals(Object obj);

    default int compareTo(MultipleHMKeys othr){
        return Comparator.comparing(MultipleHMKeys::getK1)
                .thenComparing(MultipleHMKeys::getK2)
                .thenComparing(MultipleHMKeys::getK3)
                .thenComparing(MultipleHMKeys::getK4)
                .thenComparing(MultipleHMKeys::getK5)
                .compare(this, othr);
    }

    MultipleHMKeys[] splitNgramTo1grams();
}
