/** * Transforms a {@link PtuFlexOffer} to its corresponding DTO object. * * @param ptuFlexOffer {@link PtuFlexOffer} database object. * @return a {@link PtuFlexOfferDto} DTO object. */ public static PtuFlexOfferDto transformPtuFlexOffer(PtuFlexOffer ptuFlexOffer) { if (ptuFlexOffer == null) { return null; } PtuFlexOfferDto ptuFlexOfferDto = new PtuFlexOfferDto(); ptuFlexOfferDto.setPower(ptuFlexOffer.getPower()); ptuFlexOfferDto.setPrice(ptuFlexOffer.getPrice()); ptuFlexOfferDto.setPtuIndex(BigInteger.valueOf(ptuFlexOffer.getPtuContainer().getPtuIndex())); return ptuFlexOfferDto; }
/** * Transforms a complete list of {@link PtuFlexOffer} to a {@link FlexOfferDto}. * * @param ptuFlexOffers a {@link java.util.List} of {@link PtuFlexOffer}. * @return a {@link FlexOfferDto}. */ public static FlexOfferDto transformPtuFlexOffers(List<PtuFlexOffer> ptuFlexOffers) { if (ptuFlexOffers == null || ptuFlexOffers.isEmpty()) { return null; } PtuFlexOffer firstPtuFlexOffer = ptuFlexOffers.get(0); FlexOfferDto flexOfferDto = new FlexOfferDto(); flexOfferDto.setParticipantDomain(firstPtuFlexOffer.getParticipantDomain()); flexOfferDto.setConnectionGroupEntityAddress( firstPtuFlexOffer.getConnectionGroup().getUsefIdentifier()); flexOfferDto.setPeriod(firstPtuFlexOffer.getPtuContainer().getPtuDate()); flexOfferDto.setFlexRequestSequenceNumber(firstPtuFlexOffer.getFlexRequestSequence()); flexOfferDto.setSequenceNumber(firstPtuFlexOffer.getSequence()); ptuFlexOffers .stream() .forEach(ptuFlexOffer -> flexOfferDto.getPtus().add(transformPtuFlexOffer(ptuFlexOffer))); return flexOfferDto; }