feat: Currency symbols enum

This commit is contained in:
Piotr Dec 2024-06-25 00:24:18 +02:00
parent f42dcce74b
commit 11d6e41c98
Signed by: stawros
GPG key ID: F89F27AD8F881A91
22 changed files with 248 additions and 129 deletions

View file

@ -2,6 +2,7 @@ package eu.ztsh.wymiana.util;
import eu.ztsh.wymiana.data.entity.CurrencyEntity;
import eu.ztsh.wymiana.model.Currency;
import eu.ztsh.wymiana.model.Symbol;
import java.util.List;
import java.util.Map;
@ -17,12 +18,12 @@ public class CurrencyMapper {
return new CurrencyEntity(pesel, pojo.symbol(), pojo.amount());
}
public static Map<String, Currency> entitiesToPojoMap(List<CurrencyEntity> values) {
public static Map<Symbol, Currency> entitiesToPojoMap(List<CurrencyEntity> values) {
return values.stream().map(CurrencyMapper::entityToPojo)
.collect(Collectors.toMap(Currency::symbol, pojo -> pojo));
}
public static List<CurrencyEntity> pojoMapToEntities(Map<String, Currency> currencies, String pesel) {
public static List<CurrencyEntity> pojoMapToEntities(Map<Symbol, Currency> currencies, String pesel) {
return currencies.values().stream().map(entry -> pojoToEntity(entry, pesel)).toList();
}