class SetMelodicSynthEvent implements IEventChain {

    public LongestMatchResponse getLongestMatch(List<BachChorale> bachChorales, List<HarmonyExtraction> harmonyExtractions) {

        LongestMatchResponse longestMatchResponse = new LongestMatchResponse();

        for (int currentLength = 0; currentLength < harmonyExtractions.size(); currentLength++) {

            List<HarmonyExtraction> extractionSubset = harmonyExtractions.subList(0, currentLength + 1);

            for (int i = 0; i < bachChorales.size() - extractionSubset.size(); i++) {

                LongestMatchResponse currentMatchResponse = new LongestMatchResponse();

                for (int subSetIndex = 0; subSetIndex < extractionSubset.size(); subSetIndex++) {
                    //compare
                    if(extractionSubset.get(subSetIndex) != null){
                        if (bachChorales.get(i + subSetIndex).getChord().equalsIgnoreCase(extractionSubset.get(subSetIndex).getChordname())) {
                            currentMatchResponse.addMatchingChord(bachChorales.get(i + subSetIndex));
                        }
                    }
                }

                if (longestMatchResponse == null || currentMatchResponse.getMatch().size() > longestMatchResponse.getMatch().size()) {
                    if(matchesListPrefix(currentMatchResponse.getMatch(), extractionSubset)){
                        longestMatchResponse = currentMatchResponse;
                    }
                }
            }

            String test = "";
        }

        return longestMatchResponse;
    }

    @Autowired public  SetMelodicSynthEvent(MelodyGenerator melodydGenerator, MelodicExtractor melodicExtractor, IBachChoraleDal bachChoraleDal);

}