本文整理匯總了Java中com.google.openrtb.OpenRtb.BidRequest.getImpList方法的典型用法代碼示例。如果您正苦於以下問題:Java BidRequest.getImpList方法的具體用法?Java BidRequest.getImpList怎麽用?Java BidRequest.getImpList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.openrtb.OpenRtb.BidRequest
的用法示例。
在下文中一共展示了BidRequest.getImpList方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: impWithId
import com.google.openrtb.OpenRtb.BidRequest; //導入方法依賴的package包/類
/**
* Finds an {@link Imp} by ID.
*
* @return The {@link Imp}s that has the given id, or {@code null} if not found.
*/
@Nullable public static Imp impWithId(BidRequest request, String id) {
checkNotNull(id);
for (Imp imp : request.getImpList()) {
if (imp.getId().equals(id)) {
return imp;
}
}
return null;
}
示例2: bannerImpWithId
import com.google.openrtb.OpenRtb.BidRequest; //導入方法依賴的package包/類
/**
* Find an {@link Imp} by its ID and its {@link Banner}'s ID.
*
* @param impId Imp ID; optional if the Banner IDs are unique within the request
* @param bannerId Banner ID
* @return The {@link Imp} for a given impression ID x banner ID, or {@code null} if not found
*/
@Nullable public static Imp bannerImpWithId(
BidRequest request, @Nullable String impId, String bannerId) {
checkNotNull(bannerId);
for (Imp imp : request.getImpList()) {
if ((impId == null || imp.getId().equals(impId))
&& imp.hasBanner() && imp.getBanner().getId().equals(bannerId)) {
return imp;
}
}
return null;
}
示例3: writeBidRequestFields
import com.google.openrtb.OpenRtb.BidRequest; //導入方法依賴的package包/類
protected void writeBidRequestFields(BidRequest req, JsonGenerator gen) throws IOException {
gen.writeStringField("id", req.getId());
if (checkRequired(req.getImpCount())) {
gen.writeArrayFieldStart("imp");
for (Imp imp : req.getImpList()) {
writeImp(imp, gen);
}
gen.writeEndArray();
}
switch (req.getDistributionchannelOneofCase()) {
case SITE:
gen.writeFieldName("site");
writeSite(req.getSite(), gen);
break;
case APP:
gen.writeFieldName("app");
writeApp(req.getApp(), gen);
break;
case DISTRIBUTIONCHANNELONEOF_NOT_SET:
checkRequired(false);
}
if (req.hasDevice()) {
gen.writeFieldName("device");
writeDevice(req.getDevice(), gen);
}
if (req.hasUser()) {
gen.writeFieldName("user");
writeUser(req.getUser(), gen);
}
if (req.hasTest()) {
writeIntBoolField("test", req.getTest(), gen);
}
if (req.hasAt()) {
writeEnumField("at", req.getAt(), gen);
}
if (req.hasTmax()) {
gen.writeNumberField("tmax", req.getTmax());
}
writeStrings("wseat", req.getWseatList(), gen);
if (req.hasAllimps()) {
writeIntBoolField("allimps", req.getAllimps(), gen);
}
writeStrings("cur", req.getCurList(), gen);
writeContentCategories("bcat", req.getBcatList(), gen);
writeStrings("badv", req.getBadvList(), gen);
if (req.hasRegs()) {
gen.writeFieldName("regs");
writeRegs(req.getRegs(), gen);
}
writeStrings("bapp", req.getBappList(), gen);
writeStrings("bseat", req.getBseatList(), gen);
writeStrings("wlang", req.getWlangList(), gen);
if (req.hasSource()) {
gen.writeFieldName("source");
writeSource(req.getSource(), gen);
}
}
示例4: impsWith
import com.google.openrtb.OpenRtb.BidRequest; //導入方法依賴的package包/類
/**
* Optimized code for most filtered lookups. This is worth the effort
* because bidder code may invoke these lookup methods intensely;
* common cases like everything-filtered or nothing-filtered are very dominant;
* and simpler code previously used needed lots of temporary collections.
*
* @param request Container of impressions
* @param impFilter Filters impressions; will be executed exactly once,
* and only for impressions that pass the banner/video type filters.
* The constants {@link #IMP_NONE} and {@link #IMP_ALL} allow
* more efficient execution when you want to filter none/all impressions.
* @return Immutable or unmodifiable view for the filtered impressions
*/
public static Iterable<Imp> impsWith(BidRequest request, Predicate<Imp> impFilter) {
checkNotNull(impFilter);
List<Imp> imps = request.getImpList();
if (imps.isEmpty() || impFilter == IMP_ALL) {
return imps;
} else if (impFilter == IMP_NONE) {
return ImmutableList.of();
}
boolean included = impFilter.test(imps.get(0));
int size = imps.size(), i;
for (i = 1; i < size; ++i) {
if (impFilter.test(imps.get(i)) != included) {
break;
}
}
if (i == size) {
return included
? imps // Unmodifiable, comes from protobuf
: ImmutableList.<Imp>of();
}
int headingSize = i;
return new FluentIterable<Imp>() {
@Override public Iterator<Imp> iterator() {
Iterator<Imp> unfiltered = imps.iterator();
return new AbstractIterator<Imp>() {
private int heading = 0;
@Override protected Imp computeNext() {
while (unfiltered.hasNext()) {
Imp imp = unfiltered.next();
if ((heading++ < headingSize)
? included
: impFilter.test(imp)) {
return imp;
}
}
return endOfData();
}};
}};
}