openrtb-core/src/main/java/com/google/openrtb/util/OpenRtbUtils.java
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);
  }
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);
  }
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)}