package de.effigenix.application.shared;

import de.effigenix.shared.common.Country;
import de.effigenix.shared.common.CountryRepository;

import java.util.List;

public class ListCountries {

    private final CountryRepository countryRepository;

    public ListCountries(CountryRepository countryRepository) {
        this.countryRepository = countryRepository;
    }

    public List<Country> execute(String query) {
        if (query == null || query.isBlank()) {
            return countryRepository.findAll();
        }
        return countryRepository.search(query);
    }
}
