Имплементируй первый метод default List<EscrowIvScheduleRow>…
- User
Имплементируй первый метод default List ofDto(List scheduleDto) {
}
default EscrowIvScheduleRow ofDto(SpecialValueIVParamDto scheduleDto, int order) { return EscrowIvScheduleRow.builder() .value(scheduleDto.getFrom()) .periodEnd(scheduleDto.getTo()) .order(order) .build(); }
И ofDomain 2шт
пиши код кратко, используя optional стримы и тому подобное
- Assistant
Для имплементации метода
ofDtoи создания методовofDomain, используем Java Streams и Optional для краткости и выразительности кода. Вот как это можно сделать:default List<EscrowIvScheduleRow> ofDto(List<SpecialValueIVParamDto> scheduleDto) { return Optional.ofNullable(scheduleDto) .orElse(Collections.emptyList()) .stream() .map(dto -> ofDto(dto, scheduleDto.indexOf(dto))) .collect(Collectors.toList()); } default List<SpecialValueIVParamDto> ofDomain(List<EscrowIvScheduleRow> scheduleRows) { return Optional.ofNullable(scheduleRows) .orElse(Collections.emptyList()) .stream() .map(this::ofDomain) .collect(Collectors.toList()); } default SpecialValueIVParamDto ofDomain(EscrowIvScheduleRow scheduleRow) { return SpecialValueIVParamDto.builder() .from(scheduleRow.getValue()) .to(scheduleRow.getPeriodEnd()) .build(); } - User
Еще такая особенность, надо public class SpecialValueIVParamDto { private int order; private BigDecimal from; private int to; private int value; }
Заполнить from автоматически, на основании предудыщего значения to. Типо конец периода совпадает с началом следующего! Но periodEnd в последнем периоде не задается (условно считается бесконечностью).
- Assistant