feat: POJO mappers
This commit is contained in:
parent
b947f95305
commit
3121caf8f7
3 changed files with 68 additions and 0 deletions
24
src/main/java/eu/ztsh/wymiana/util/CurrencyMapper.java
Normal file
24
src/main/java/eu/ztsh/wymiana/util/CurrencyMapper.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package eu.ztsh.wymiana.util;
|
||||
|
||||
import eu.ztsh.wymiana.data.entity.CurrencyEntity;
|
||||
import eu.ztsh.wymiana.model.Currency;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CurrencyMapper {
|
||||
|
||||
public static Currency entityToPojo(CurrencyEntity entity) {
|
||||
return new Currency(entity.getSymbol(), entity.getAmount());
|
||||
}
|
||||
|
||||
public static Map<String, Currency> entitiesToPojoMap(List<CurrencyEntity> values) {
|
||||
return values.stream().map(CurrencyMapper::entityToPojo)
|
||||
.collect(Collectors.toMap(Currency::symbol, pojo -> pojo));
|
||||
}
|
||||
|
||||
private CurrencyMapper() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue