package org.lodder.subtools.multisubdownloader.lib.control.subtitles;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.lodder.subtools.multisubdownloader.lib.control.subtitles.filters.ExactNameFilter;
import org.lodder.subtools.multisubdownloader.lib.control.subtitles.filters.Filter;
import org.lodder.subtools.multisubdownloader.lib.control.subtitles.filters.KeywordFilter;
import org.lodder.subtools.multisubdownloader.lib.control.subtitles.filters.ReleasegroupFilter;
import org.lodder.subtools.multisubdownloader.settings.model.Settings;
import org.lodder.subtools.sublibrary.logging.Logger;
import org.lodder.subtools.sublibrary.model.Release;
import org.lodder.subtools.sublibrary.model.Subtitle;

public class Filtering {

  private Settings settings;
  private Filter exactname;
  private Filter keyword;
  private Filter releasegroup;

  public Filtering(Settings settings) {
    this.settings = settings;
    exactname = new ExactNameFilter();
    keyword = new KeywordFilter();
    releasegroup = new ReleasegroupFilter();
  }

  public List<Subtitle> getFiltered(List<Subtitle> listFoundSubtitles, Release release) {
    Logger.instance.trace("Filtering", "getFiltered", "");

    List<Subtitle> listFilteredSubtitles;
    listFilteredSubtitles = new ArrayList<Subtitle>();

    if (settings.isOptionSubtitleExcludeHearingImpaired()) {
      Iterator<Subtitle> i = listFoundSubtitles.iterator();
      while (i.hasNext()) {
        Subtitle sub = i.next();
        if (sub.isHearingImpaired()) i.remove();
      }
    }
    
    if (settings.isOptionSubtitleKeywordMatch()) {
      listFilteredSubtitles = keyword.doFilter(release, listFoundSubtitles);
      if (listFilteredSubtitles.size() > 0) listFoundSubtitles = listFilteredSubtitles;
      listFilteredSubtitles = releasegroup.doFilter(release, listFoundSubtitles);
      if (listFilteredSubtitles.size() > 0) listFoundSubtitles = listFilteredSubtitles;
    }

    if (settings.isOptionSubtitleExactMatch()) {
      listFilteredSubtitles = exactname.doFilter(release, listFoundSubtitles);
      if (listFilteredSubtitles.size() > 0) listFoundSubtitles = listFilteredSubtitles;
    }

    return listFoundSubtitles;
  }

}

@@ -582,62 +582,8 @@
 gs;%0A
-import org.lodder.subtools.sublibrary.logging.Logger;%0A
 impo
@@ -684,16 +684,73 @@
 ubtitle;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0Apublic
@@ -882,16 +882,100 @@
 segroup;
+%0A  %0A  private static final Logger LOGGER = LoggerFactory.getLogger(Filtering.class);
 %0A%0A  publ
@@ -1261,30 +1261,21 @@
    L
-ogger.instance
+OGGER
 .trace(%22
 Filt
@@ -1274,37 +1274,88 @@
 ce(%22
+get
 Filter
-ing%22, %22getFiltered%22, %22%22
+ed: release %5B%7B%7D%5D available subtitles %5B%7B%7D%5D%22, release, listFoundSubtitles
 );%0A%0A

Convert Filtering from old logger to new LOGGER slf4j