public List<CountryDto> getAll() { return countryRepository .findAll() .stream() .map(countryAssembler.convertCountryToDto()) .collect(Collectors.toList()); }
@Cacheable("countriesCache") public List<CountryDto> getByName(String name) { Preconditions.checkArgument(StringUtils.isNotBlank(name), "Name cannot be blank"); return countryRepository .findByName(name) .stream() .map(countryAssembler.convertCountryToDto()) .collect(Collectors.toList()); }
public void add(CountryDto countryDto) { Preconditions.checkNotNull(countryDto, "countryDto cannot be null"); Country country = countryAssembler.transformCountryDtoToEntity().apply(countryDto); entityManager.persist(country); }