
package de.ivu.elect.business.konfiguration.control;

import java.util.List;
import java.util.stream.Collectors;

import de.ivu.elect.business.konfiguration.boundary.CustomParameterSearchParameters;
import de.ivu.elect.business.konfiguration.entity.CustomParameter;
import de.ivu.elect.business.konfiguration.entity.CustomParameterTemplate;

public class CustomParameterSearchResult<T extends CustomParameterTemplate, E extends CustomParameter<T>> {

  public CustomParameterSearchResult() {
    super();
  }

  public List<E> getSearchResult(List<E> parameters, CustomParameterSearchParameters searchParameters) {
    return parameters.stream() //
        .filter(parameter -> !searchParameters.hasKategorie() || parameter.matchesKategorie(searchParameters.getKategorie())) //
        .filter(parameter -> !searchParameters.isNurUngueltige() || !parameter.validate().isEmpty()) //
        .sorted(new CustomParameterByTemplateComparator<>()) //
        .collect(Collectors.toList());
  }

}
