当前位置: 首页>>代码示例>>Java>>正文


Java Imp类代码示例

本文整理汇总了Java中com.google.openrtb.OpenRtb.BidRequest.Imp的典型用法代码示例。如果您正苦于以下问题:Java Imp类的具体用法?Java Imp怎么用?Java Imp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Imp类属于com.google.openrtb.OpenRtb.BidRequest包,在下文中一共展示了Imp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addFilters

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
/**
 * Adds "impression type" subfilters to a base filter, to further restricts impressions
 * that contain a banner, video and/or native object.
 *
 * @param baseFilter base filter for impressions
 * @param banner {@code true} to include impressions with
 * {@link com.google.openrtb.OpenRtb.BidRequest.Imp.Banner}s
 * @param video {@code true} to include impressions with
 * {@link com.google.openrtb.OpenRtb.BidRequest.Imp.Video}s
 * @param nativ {@code true} to include impressions with
 * {@link com.google.openrtb.OpenRtb.BidRequest.Imp.Native}s
 * @return A filter in the form: {@code baseFilter AND (banner OR video OR native)}
 */
public static Predicate<Imp> addFilters(
    Predicate<Imp> baseFilter, boolean banner, boolean video, boolean nativ) {
  int orCount = (banner ? 1 : 0) + (video ? 1 : 0) + (nativ ? 1 : 0);
  if (baseFilter == IMP_NONE || orCount == 0) {
    return baseFilter;
  }

  Predicate<Imp> typeFilter = null;
  if (banner) {
    typeFilter = Imp::hasBanner;
  }
  if (video) {
    typeFilter = typeFilter == null ? Imp::hasVideo : typeFilter.or(Imp::hasVideo);
  }
  if (nativ) {
    typeFilter = typeFilter == null ? Imp::hasNative : typeFilter.or(Imp::hasNative);
  }

  return baseFilter == IMP_ALL ? typeFilter : baseFilter.and(typeFilter);
}
 
开发者ID:google,项目名称:openrtb,代码行数:34,代码来源:OpenRtbUtils.java

示例2: registerAdxExt

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
/**
 * Configures a JSON factory with support for the {@link AdxExt} extensions.
 */
public static OpenRtbJsonFactory registerAdxExt(OpenRtbJsonFactory factory) {
  return factory
      .register(new ImpExtReader(), Imp.Builder.class)
      .register(new ImpExtWriter(), ImpExt.class, Imp.class)
      .register(new BidExtReader(), Bid.Builder.class)
      .register(new BidExtWriter(), BidExt.class, Bid.class)
      .register(new BidResponseExtReader(), BidResponse.Builder.class)
      .register(new BidResponseExtWriter(), BidResponseExt.class, BidResponse.class)
      .register(new SiteExtReader(), Site.Builder.class)
      .register(new SiteExtWriter(), SiteExt.class, Site.class)
      .register(new NativeRequestExtReader(), NativeRequest.Builder.class)
      .register(new NativeRequestExtWriter(), NativeRequestExt.class, NativeRequest.class);
}
 
开发者ID:google,项目名称:openrtb-doubleclick,代码行数:17,代码来源:AdxExtUtils.java

示例3: readImp

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
public final Imp.Builder readImp(JsonParser par) throws IOException {
  Imp.Builder imp = Imp.newBuilder();
  for (startObject(par); endObject(par); par.nextToken()) {
    String fieldName = getCurrentName(par);
    if (par.nextToken() != JsonToken.VALUE_NULL) {
      readImpField(par, imp, fieldName);
    }
  }
  return imp;
}
 
开发者ID:google,项目名称:openrtb,代码行数:11,代码来源:OpenRtbJsonReader.java

示例4: impWithId

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的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;
}
 
开发者ID:google,项目名称:openrtb,代码行数:17,代码来源:OpenRtbUtils.java

示例5: bannerImpWithId

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的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;
}
 
开发者ID:google,项目名称:openrtb,代码行数:21,代码来源:OpenRtbUtils.java

示例6: testRequest_5_1_1

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
@Test
public void testRequest_5_1_1() {
  BidRequest.newBuilder()
      .setId("1234534625254")
      .setAt(AuctionType.SECOND_PRICE)
      .setTmax(120)
      .addImp(Imp.newBuilder()
          .setId("1")
          .setBanner(Banner.newBuilder()
              .setW(300)
              .setH(250)
              .setPos(AdPosition.ABOVE_THE_FOLD)
              .addBattr(CreativeAttribute.USER_INTERACTIVE)))
       .addBadv("company1.com")
       .addBadv("company2.com")
       .setSite(Site.newBuilder()
           .setId("234563")
           .setName("Site ABCD")
           .setDomain("siteabcd.com")
           .addAllCat(asList("IAB2-1", "IAB2-2"))
           .setPrivacypolicy(true)
           .setPage("http://siteabcd.com/page.htm")
           .setRef("http://referringsite.com/referringpage.htm")
           .setPublisher(Publisher.newBuilder()
               .setId("pub12345")
               .setName("Publisher A"))
           .setContent(Content.newBuilder()
               .setKeywords("keyword a,keyword b,keyword c")))
       .setDevice(Device.newBuilder()
           .setIp("64.124.253.1")
           .setUa("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.16)")
           .setOs("OS X")
           .setFlashver("10.1")
           .setJs(true))
       .setUser(User.newBuilder()
           .setId("45asdf987656789adfad4678rew656789")
           .setBuyeruid("5df678asd8987656asdf78987654"))
   .build();
}
 
开发者ID:google,项目名称:openrtb,代码行数:40,代码来源:ProtobufTest.java

示例7: testRequest_emptyMessages

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testRequest_emptyMessages() throws IOException {
  OpenRtbJsonFactory jsonFactory = newJsonFactory();
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0").build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0"))
      .setDevice(Device.newBuilder())
      .setApp(App.newBuilder())
      .setUser(User.newBuilder())
      .setRegs(Regs.newBuilder())
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0")
          .setBanner(Banner.newBuilder())
          .setPmp(Pmp.newBuilder()))
      .addImp(Imp.newBuilder().setId("0")
          .setBanner(Banner.newBuilder()
              .addFormat(Banner.Format.newBuilder())))
      .setDevice(Device.newBuilder().setGeo(Geo.newBuilder()))
      .setSite(Site.newBuilder())
      .setUser(User.newBuilder().addData(Data.newBuilder()))
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0")
          .setVideo(Video.newBuilder())
          .setAudio(Audio.newBuilder())
          .setPmp(Pmp.newBuilder().addDeals(Pmp.Deal.newBuilder().setId("0"))))
      .addImp(Imp.newBuilder().setId("0")
          .setVideo(Video.newBuilder().setCompanionad21(Video.CompanionAd.newBuilder())))
      .setSite(Site.newBuilder()
          .setContent(Content.newBuilder())
          .setPublisher(Publisher.newBuilder()))
          .setUser(User.newBuilder().addData(Data.newBuilder().addSegment(Segment.newBuilder())))
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .setSite(Site.newBuilder()
          .setContent(Content.newBuilder().setProducer(Producer.newBuilder())))
      .build());
}
 
开发者ID:google,项目名称:openrtb,代码行数:41,代码来源:OpenRtbJsonTest.java

示例8: process

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
private String process(String snippet, boolean full) {
  BidRequest request = BidRequest.newBuilder()
      .setId("1")
      .addImp(Imp.newBuilder()
          .setId("1")).build();
  BidResponse.Builder response = createBidResponse(snippet, full);
  SnippetProcessorContext ctx = new SnippetProcessorContext(request, response);
  ctx.setBid(response.getSeatbidBuilder(0).getBidBuilder(0));
  return processor.process(ctx, snippet);
}
 
开发者ID:google,项目名称:openrtb,代码行数:11,代码来源:SnippetProcessorTest.java

示例9: testNoData

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
@Test
public void testNoData() {
  BidRequest request = BidRequest.newBuilder()
      .setId("req1")
      .addImp(Imp.newBuilder()
          .setId("imp1")
          .setBanner(Banner.newBuilder()))
      .build();
  Bid.Builder bid = Bid.newBuilder()
      .setId("bid1")
      .setImpid("imp1")
      .setAdm(
            OpenRtbMacros.AUCTION_AD_ID.key()
          + OpenRtbMacros.AUCTION_BID_ID.key()
          + OpenRtbMacros.AUCTION_CURRENCY.key()
          + OpenRtbMacros.AUCTION_SEAT_ID.key())
      .setPrice(10000);
  BidResponse.Builder resp = BidResponse.newBuilder()
      .addSeatbid(SeatBid.newBuilder().addBid(bid));
  OpenRtbSnippetProcessor processor = new OpenRtbSnippetProcessor(true);
  processor.process(new SnippetProcessorContext(request, resp));
  bid = resp.getSeatbidBuilder(0).getBidBuilder(0);
  assertThat(bid.getAdm()).isEmpty();
}
 
开发者ID:google,项目名称:openrtb,代码行数:25,代码来源:OpenRtbSnippetProcessorTest.java

示例10: testRequest_imps

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
@Test
public void testRequest_imps() {
  BidRequest request = BidRequest.newBuilder().setId("1").build();
  assertThat(OpenRtbUtils.impsWith(request, imp -> true)).isEmpty();
  request = request.toBuilder().addImp(Imp.newBuilder().setId("1")).build();
  assertThat(OpenRtbUtils.impsWith(request, imp -> true)).hasSize(1);
  assertThat(OpenRtbUtils.impsWith(request, imp -> "notfound".equals(imp.getId()))).isEmpty();
  assertThat(OpenRtbUtils.impsWith(request, imp -> "1".equals(imp.getId()))).hasSize(1);
  assertThat(OpenRtbUtils.impWithId(request, "1")).isNotNull();
  assertThat(OpenRtbUtils.impStreamWith(request, imp -> "1".equals(imp.getId())).count())
      .isEqualTo(1);
}
 
开发者ID:google,项目名称:openrtb,代码行数:13,代码来源:OpenRtbUtilsTest.java

示例11: testAddFilter_specialCases

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
@Test
public void testAddFilter_specialCases() {
  Predicate<Imp> pred = imp -> true;
  assertThat(OpenRtbUtils.addFilters(pred, false, false, false)).isSameAs(pred);
  assertThat(OpenRtbUtils.addFilters(OpenRtbUtils.IMP_NONE, true, true, true))
      .isSameAs(OpenRtbUtils.IMP_NONE);
  assertThat(OpenRtbUtils.addFilters(OpenRtbUtils.IMP_ALL, true, true, true))
      .isNotSameAs(OpenRtbUtils.IMP_ALL);  // Mostly for coverage
}
 
开发者ID:google,项目名称:openrtb,代码行数:10,代码来源:OpenRtbUtilsTest.java

示例12: process

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
private String process(DoubleClickSnippetProcessor processor, String snippet) {
  BidRequest request = BidRequest.newBuilder()
      .setId("1")
      .addImp(Imp.newBuilder()
          .setId("1")).build();
  BidResponse.Builder response = createBidResponse(snippet);
  SnippetProcessorContext ctx = new SnippetProcessorContext(request, response);
  ctx.setBid(response.getSeatbidBuilder(0).getBidBuilder(0));
  return processor.process(ctx, snippet);
}
 
开发者ID:google,项目名称:openrtb-doubleclick,代码行数:11,代码来源:DoubleClickSnippetProcessorTest.java

示例13: testRequest

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
@Test
public void testRequest() throws IOException {
  testRequest(BidRequest.newBuilder()
      .setId("0")
      .addImp(Imp.newBuilder()
          .setId("1")
          .setNative(Native.newBuilder()
              .setRequestNative(NativeRequest.newBuilder()
                    .setExtension(AdxExt.nativeExt, NativeRequestExt.newBuilder()
                        .setStyleId(12)
                        .setStyleWidth(200)
                        .setStyleHeight(100)
                        .setStyleLayoutType(LayoutType.PIXEL)
                        .build())))
          .setExtension(AdxExt.imp, ImpExt.newBuilder()
              .addAllBillingId(asList(100L, 101L, 999999999999999999L))
              .addAllPublisherSettingsListId(asList(200L, 201L, 8888888888888888888L))
              .addAllAllowedVendorType(asList(300, 301, 302))
              .addAllPublisherParameter(asList("a", "b", "c"))
              .setDfpAdUnitCode("abc")
              .setIsRewardedInventory(true)
              .setAmpad(AmpAdRequirementType.AMP_AD_REQUIRED)
              .build()))
      .setSite(Site.newBuilder()
          .setDomain("mysite.com")
          .setExtension(AdxExt.site, SiteExt.newBuilder()
              .setAmp(SiteExt.AmpPage.DIALECT_HTML_AMP)
              .build()))
      .build());
}
 
开发者ID:google,项目名称:openrtb-doubleclick,代码行数:31,代码来源:AdxExtJsonTest.java

示例14: readImpField

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的package包/类
protected void readImpField(JsonParser par, Imp.Builder imp, String fieldName)
    throws IOException {
  switch (fieldName) {
    case "id":
      imp.setId(par.getText());
      break;
    case "banner":
      imp.setBanner(readBanner(par));
      break;
    case "video":
      imp.setVideo(readVideo(par));
      break;
    case "audio":
      imp.setAudio(readAudio(par));
      break;
    case "native":
      imp.setNative(readNative(par));
      break;
    case "displaymanager":
      imp.setDisplaymanager(par.getText());
      break;
    case "displaymanagerver":
      imp.setDisplaymanagerver(par.getText());
      break;
    case "instl":
      imp.setInstl(par.getValueAsBoolean());
      break;
    case "tagid":
      imp.setTagid(par.getText());
      break;
    case "bidfloor":
      imp.setBidfloor(par.getValueAsDouble());
      break;
    case "bidfloorcur":
      imp.setBidfloorcur(par.getText());
      break;
    case "secure":
      imp.setSecure(par.getValueAsBoolean());
      break;
    case "iframebuster":
      for (startArray(par); endArray(par); par.nextToken()) {
        imp.addIframebuster(par.getText());
      }
      break;
    case "pmp":
      imp.setPmp(readPmp(par));
      break;
    case "clickbrowser":
      imp.setClickbrowser(par.getValueAsBoolean());
      break;
    case "exp":
      imp.setExp(par.getIntValue());
      break;
    case "metric":
      for (startArray(par); endArray(par); par.nextToken()) {
        imp.addMetric(readMetric(par));
      }
      break;
    default:
      readOther(imp, par, fieldName);
  }
}
 
开发者ID:google,项目名称:openrtb,代码行数:63,代码来源:OpenRtbJsonReader.java

示例15: writeBidRequestFields

import com.google.openrtb.OpenRtb.BidRequest.Imp; //导入依赖的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);
  }
}
 
开发者ID:google,项目名称:openrtb,代码行数:58,代码来源:OpenRtbJsonWriter.java


注:本文中的com.google.openrtb.OpenRtb.BidRequest.Imp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。