amezenin / encyclopedia-kn

0 stars 0 forks source link

It is time to use functional programming #8

Open vahid-forghani opened 2 years ago

vahid-forghani commented 2 years ago

https://github.com/amezenin/encyclopedia-kn/blob/d53e5f3c72c28001a877e8c4e140c8eff7fe7b01/src/main/java/com/knits/product/service/mapper/ArticleMapper.java#L90

using functional programming is highly recommended.

return entityList.stream().map(this::toDto).collect(Collectors.toList());

then you can remove all of these lines :

List<ArticleDTO> list = new ArrayList<>(entityList.size());
        for (Article entity : entityList) {
            list.add(toDto(entity));
        }
        return list;
amezenin commented 2 years ago

https://github.com/amezenin/encyclopedia-kn/blob/d53e5f3c72c28001a877e8c4e140c8eff7fe7b01/src/main/java/com/knits/product/service/mapper/ArticleMapper.java#L90

using functional programming is highly recommended.

return entityList.stream().map(this::toDto).collect(Collectors.toList());

then you can remove all of these lines :

List<ArticleDTO> list = new ArrayList<>(entityList.size());
        for (Article entity : entityList) {
            list.add(toDto(entity));
        }
        return list;

Thank you! Fixed.