class HarmonicLoopWeighter {

    public void assignThemeWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit) {

        ProgressionUnitBar progressionUnitBar = currentProgressionUnit.getProgressionUnitBars().get(indexToWeight);

        for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) {

//            Integer currentLoopId = progressionUnitBar.getHarmonicLoop().getId();
            Integer currentLoopOptionId = progressionUnitBar.getHarmonicLoopOptions().get(i).getId();

            //ONE
            if (indexToWeight.equals(LoopPositions.POSITION_ONE) && priorProgressionUnit != null) {
                if (priorProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop() != null) {
                    Integer previousLoopId = priorProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop().getId();

                    if (currentLoopOptionId.equals(previousLoopId)) {
                        progressionUnitBar.getHarmonicLoopOptions().get(i).setThemeWeight(WeightClass.GOOD);
                        continue;
                    }
                }
            }

            //TWO
            if (indexToWeight.equals(LoopPositions.POSITION_TWO)) {
                if (currentProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).getHarmonicLoop() != null) {
                    HarmonicLoop harmonicLoopOne = currentProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).getHarmonicLoop();
                    if (harmonicLoopOne != null && harmonicLoopOne.getId().equals(currentLoopOptionId)) {
                        progressionUnitBar.getHarmonicLoopOptions().get(i).setThemeWeight(WeightClass.GOOD);
                        continue;
                    }
                }
            }

            //THREE
            if (indexToWeight.equals(LoopPositions.POSITION_THREE)) {
                if (currentProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).getHarmonicLoop() != null) {
                    HarmonicLoop harmonicLoopTwo = currentProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).getHarmonicLoop();
                    if (harmonicLoopTwo != null && harmonicLoopTwo.getId().equals(currentLoopOptionId)) {
                        progressionUnitBar.getHarmonicLoopOptions().get(i).setThemeWeight(WeightClass.GOOD);
                        continue;
                    }
                }
            }

            //FOUR
            if (indexToWeight.equals(LoopPositions.POSITION_FOUR)) {
                if (currentProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop() != null) {
                    HarmonicLoop harmonicLoopThree = currentProgressionUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop();
                    if (harmonicLoopThree != null && harmonicLoopThree.getId().equals(currentLoopOptionId)) {
                        progressionUnitBar.getHarmonicLoopOptions().get(i).setThemeWeight(WeightClass.GOOD);
                        continue;
                    }
                }
            }
        }
    }

    @Autowired public  HarmonicLoopWeighter(IRhythmWeighter rhythmWeighter, HarmonicLoopTimeseriesClassifier harmonicLoopTimeseriesClassifier, @Value("${bypass_eq_ratings}") boolean bypassEqRatings);

}