RTBHouse: Add PMP Removal and Publisher ID Extraction by pjaworski-rtbh · Pull Request #4229 · prebid/prebid-server-java
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I gave you an incorrect refactoring example for your case.
It should have been something like the following and it would be totally fine (I can spot a lot of other bidders that do similar things you try to do)
private static Site modifySite(Site site, String id) { return Optional.ofNullable(site) .map(Site::toBuilder) .map(builder -> builder.publisher(modifyPublisher(site.getPublisher(), id))) .map(Site.SiteBuilder::build) .orElse(null); } private static Publisher modifyPublisher(Publisher publisher, String id) { return Optional.ofNullable(publisher) .map(Publisher::toBuilder) .orElseGet(Publisher::builder) .id(id) .build(); }
But If you'd like to set the siteId to another target request.site.publisher.ext.prebid.publisherId I can suggest adding a publisherId property to the ExtPublisherPrebid class - but you have to make sure other bidders that uses the same class will be able to compile and the tests will pass after the changes