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; import java.util.stream.Collectors; public class CurrencyMapper { public static Currency entityToPojo(CurrencyEntity entity) { return new Currency(entity.getSymbol(), entity.getAmount()); } public static CurrencyEntity pojoToEntity(Currency pojo, String pesel) { return new CurrencyEntity(pesel, pojo.symbol(), pojo.amount()); } public static Map entitiesToPojoMap(List values) { return values.stream().map(CurrencyMapper::entityToPojo) .collect(Collectors.toMap(Currency::symbol, pojo -> pojo)); } public static List pojoMapToEntities(Map currencies, String pesel) { return currencies.values().stream().map(entry -> pojoToEntity(entry, pesel)).toList(); } private CurrencyMapper() { } }