diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index 9802e284948..2dc7925983b 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -228,7 +228,7 @@ private List updateBids(List bidderResponses, final Bid updatedBid = updateBid( receivedBid, bidType, bidder, videoStoredDataResult, auctionContext, eventsContext, lineItemId); - modifiedBidderBids.add(bidderBid.with(updatedBid)); + modifiedBidderBids.add(bidderBid.toBuilder().bid(updatedBid).build()); } final BidderSeatBid modifiedSeatBid = seatBid.with(modifiedBidderBids); diff --git a/src/main/java/org/prebid/server/auction/ExchangeService.java b/src/main/java/org/prebid/server/auction/ExchangeService.java index 5e018c198e7..067651dfaef 100644 --- a/src/main/java/org/prebid/server/auction/ExchangeService.java +++ b/src/main/java/org/prebid/server/auction/ExchangeService.java @@ -1402,7 +1402,7 @@ private BidderBid updateBidderBidWithBidPriceChanges(BidderBid bidderBid, bidBuilder.ext(updatedBidExt); } - return bidderBid.with(bidBuilder.build()); + return bidderBid.toBuilder().bid(bidBuilder.build()).build(); } private static BidAdjustmentMediaType resolveBidAdjustmentMediaType(String bidImpId, diff --git a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java index e5c75f9cf45..2f3c2280d05 100644 --- a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java +++ b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java @@ -548,12 +548,13 @@ private BidderBid toBidderBid(Bid bid, String currency, List errors cat = Collections.emptyList(); } - return BidderBid.of( - bid.toBuilder().cat(cat).build(), - bidType(appnexus.getBidAdType()), - currency, - appnexus.getDealPriority(), - makeExtBidVideo(appnexus)); + return BidderBid.builder() + .bid(bid.toBuilder().cat(cat).build()) + .type(bidType(appnexus.getBidAdType())) + .bidCurrency(currency) + .dealPriority(appnexus.getDealPriority()) + .videoInfo(makeExtBidVideo(appnexus)) + .build(); } private static ExtBidPrebidVideo makeExtBidVideo(AppnexusBidExtAppnexus extAppnexus) { diff --git a/src/main/java/org/prebid/server/bidder/model/BidderBid.java b/src/main/java/org/prebid/server/bidder/model/BidderBid.java index af09c116968..467437d5d59 100644 --- a/src/main/java/org/prebid/server/bidder/model/BidderBid.java +++ b/src/main/java/org/prebid/server/bidder/model/BidderBid.java @@ -1,7 +1,7 @@ package org.prebid.server.bidder.model; import com.iab.openrtb.response.Bid; -import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Value; import org.prebid.server.bidder.Bidder; import org.prebid.server.proto.openrtb.ext.response.BidType; @@ -10,14 +10,10 @@ /** * Bid returned by a {@link Bidder}. */ -@AllArgsConstructor(staticName = "of") +@Builder(toBuilder = true) @Value public class BidderBid { - public static BidderBid of(Bid bid, BidType bidType, String bidCurrency) { - return BidderBid.of(bid, bidType, bidCurrency, null, null); - } - /** * bid.ext will become "response.seatbid[i].bid.ext.bidder" in the final OpenRTB response */ @@ -43,7 +39,11 @@ public static BidderBid of(Bid bid, BidType bidType, String bidCurrency) { */ ExtBidPrebidVideo videoInfo; - public BidderBid with(Bid bid) { - return BidderBid.of(bid, this.type, this.bidCurrency); + public static BidderBid of(Bid bid, BidType bidType, String bidCurrency) { + return BidderBid.builder() + .bid(bid) + .type(bidType) + .bidCurrency(bidCurrency) + .build(); } } diff --git a/src/main/java/org/prebid/server/cache/CacheService.java b/src/main/java/org/prebid/server/cache/CacheService.java index 1934bf2dc42..1cd47f20033 100644 --- a/src/main/java/org/prebid/server/cache/CacheService.java +++ b/src/main/java/org/prebid/server/cache/CacheService.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; import io.vertx.core.Future; import io.vertx.core.MultiMap; import io.vertx.core.logging.Logger; @@ -307,7 +308,7 @@ private CacheBid toCacheBid(BidInfo bidInfo, CacheTtl accountCacheTtl, boolean isVideoBid) { - final com.iab.openrtb.response.Bid bid = bidInfo.getBid(); + final Bid bid = bidInfo.getBid(); final Integer bidTtl = bid.getExp(); final Imp correspondingImp = bidInfo.getCorrespondingImp(); final Integer impTtl = correspondingImp != null ? correspondingImp.getExp() : null; @@ -466,7 +467,7 @@ private CachedCreative createJsonPutObjectOpenrtb(CacheBid cacheBid, EventsContext eventsContext) { final BidInfo bidInfo = cacheBid.getBidInfo(); - final com.iab.openrtb.response.Bid bid = bidInfo.getBid(); + final Bid bid = bidInfo.getBid(); final ObjectNode bidObjectNode = mapper.mapper().valueToTree(bid); final String eventUrl = @@ -494,7 +495,7 @@ private CachedCreative createJsonPutObjectOpenrtb(CacheBid cacheBid, */ private CachedCreative createXmlPutObjectOpenrtb(CacheBid cacheBid, String requestId, String hbCacheId) { final BidInfo bidInfo = cacheBid.getBidInfo(); - final com.iab.openrtb.response.Bid bid = bidInfo.getBid(); + final Bid bid = bidInfo.getBid(); final String vastXml = bid.getAdm(); final String customCacheKey = resolveCustomCacheKey(hbCacheId, bidInfo.getCategory()); @@ -583,17 +584,17 @@ private List toResponse(BidCacheResponse bidCacheResponse, Function toResultMap(List cacheBids, - List cacheVideoBids, - List uuids, - String hbCacheId) { + private static Map toResultMap(List cacheBids, + List cacheVideoBids, + List uuids, + String hbCacheId) { - final Map result = new HashMap<>(uuids.size()); + final Map result = new HashMap<>(uuids.size()); // here we assume "videoBids" is a sublist of "bids" // so, no need for a separate loop on "videoBids" if "bids" is not empty if (!cacheBids.isEmpty()) { - final List videoBids = cacheVideoBids.stream() + final List videoBids = cacheVideoBids.stream() .map(CacheBid::getBidInfo) .map(BidInfo::getBid) .collect(Collectors.toList()); @@ -602,7 +603,7 @@ private static Map toResultMap(List cat) {