
open_rtb.Pmp Maven / Gradle / Ivy
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package open_rtb;
/** 3.3.16 PMP Object
The “pmp” object contains a parent object for usage within the context of private marketplaces and the use of the RTB protocol to execute Direct Deals. */
public interface Pmp
extends java.util.function.Supplier,
java.lang.Comparable>,
java.io.Serializable {
/** True if all fields are set to default values. */
default boolean isDefault() {
return
isDefaultPrivateAuction() &&
isDefaultDeals();
}
/** Returns underlying object. */
T get();
/** Creates a new builder based on this object. */
Builder newBuilder();
/** An integer flag indicating that this impression is a private auction eligible only to seats named in the Direct Deals object. (e.g., 1 = bids for this impression are restricted to the deals specified and the terms thereof; 0 = all bids are accepted) */
int getPrivateAuction();
boolean isDefaultPrivateAuction();
/** A collection of “deal” objects encapsulating a list of direct deals eligible for this impression. */
java.util.List> getDeals();
boolean isDefaultDeals();
public interface Builder {
Pmp build();
Builder setPrivateAuction(int value);
Builder clearPrivateAuction();
Builder setDeals(java.util.List> value);
Builder clearDeals();
}
static class Comparator implements java.util.Comparator>, java.io.Serializable {
@Override public int compare(open_rtb.Pmp> a, open_rtb.Pmp> b) {
int _cmp;
if (0 != (_cmp = comparePrivateAuction(a, b))) return _cmp;
if (0 != (_cmp = compareDeals(a, b))) return _cmp;
return 0;
}
static private int comparePrivateAuction (open_rtb.Pmp> a, open_rtb.Pmp> b) {
final java.lang.Integer fa = a.getPrivateAuction();
final java.lang.Integer fb = b.getPrivateAuction();
return java.lang.Integer.compareUnsigned(fa, fb);
}
static private int compareDeals (open_rtb.Pmp> a, open_rtb.Pmp> b) {
final java.util.List> fa = a.getDeals();
final java.util.List> fb = b.getDeals();
int _cmp = 0; java.util.Iterator> a_it1 = fa.iterator(); java.util.Iterator> b_it1 = fb.iterator(); while (a_it1.hasNext() && b_it1.hasNext()) { if (0 != (_cmp = a_it1.next().compareTo(b_it1.next()))) return _cmp; } if (a_it1.hasNext()) return 1; if (b_it1.hasNext()) return -1; return 0;
}
static private final Comparator INSTANCE = new Comparator();
static public final long serialVersionUID = 2;
}
/** Returns comparator instance for Pmp objects. */
static java.util.Comparator> getComparator() {
return Comparator.INSTANCE;
}
@Override default int compareTo(open_rtb.Pmp> other) {
return getComparator().compare(this, other);
}
static class NativeImpl implements open_rtb.Pmp {
transient private java.lang.String json;
private int __private_auction;
transient private java.lang.Boolean is_default$private_auction;
private java.util.List> __deals;
transient private java.lang.Boolean is_default$deals;
transient private java.util.List> _deals;
private NativeImpl() {
__private_auction = 0;
is_default$private_auction = java.lang.Boolean.TRUE;
__deals = java.util.Collections.emptyList();
is_default$deals = java.lang.Boolean.TRUE;
json = "{}";
}
private NativeImpl(NativeImpl other) {
setPrivateAuction(other.getPrivateAuction());
setDeals(other.getDeals());
json = other.json;
}
@Override public NativeImpl get() {
return this;
}
@Override public Builder newBuilder() {
return newNativeImplBuilder(this);
}
private java.lang.String buildJson() {
java.lang.StringBuilder sb = new StringBuilder();
if (!isDefaultPrivateAuction()) {
sb.append((0 == sb.length()) ? "{\"private_auction\": " : ", \"private_auction\": ")
.append(__private_auction);
}
if (!isDefaultDeals()) {
sb.append((0 == sb.length()) ? "{\"deals\": " : ", \"deals\": ")
.append(__deals.stream().map(java.lang.Object::toString).collect(java.util.stream.Collectors.joining(", ", "[", "]")));
}
return (0 == sb.length()) ? "{}" : sb.append('}').toString();
}
@Override public String toString() {
if (null == json) {
json = buildJson();
}
return json;
}
@Override public int hashCode() {
return toString().hashCode();
}
@Override public boolean equals(Object other) {
if (other == this) return true;
if (other == null || !(other instanceof NativeImpl)) return false;
return toString().equals(other.toString());
}
@Override public int getPrivateAuction() {
return __private_auction;
}
@Override public boolean isDefaultPrivateAuction() {
if (null == is_default$private_auction) {
is_default$private_auction = 0 == getPrivateAuction();
}
return is_default$private_auction;
}
private void setPrivateAuction(int value) {
this.__private_auction = value;
this.is_default$private_auction = null;
this.json = null;
}
@Override public java.util.List> getDeals() {
if (null == _deals) {
_deals = java.util.Collections.unmodifiableList(__deals);
}
return _deals;
}
@Override public boolean isDefaultDeals() {
if (null == is_default$deals) {
is_default$deals = getDeals().isEmpty();
}
return is_default$deals;
}
private void setDeals(java.util.List> value) {
this.__deals = value.stream().map(open_rtb.Deal::nativeImpl).collect(java.util.stream.Collectors.toCollection(() -> new java.util.ArrayList<>(value.size())));
this.is_default$deals = null;
this.json = null;
this._deals = null;
}
static class NativeImplBuilder implements Builder {
private NativeImpl wrapped = new NativeImpl();
@Override public open_rtb.Pmp build() {
return new NativeImpl(wrapped);
}
@Override public Builder setPrivateAuction(int value) {
if (0 == value) {
return clearPrivateAuction();
}
wrapped.setPrivateAuction(value);
return this;
}
@Override public Builder clearPrivateAuction() {
wrapped.__private_auction = _DEFAULT.get().__private_auction;
wrapped.is_default$private_auction = true;
return this;
}
@Override public Builder setDeals(java.util.List> value) {
if (value.isEmpty()) {
return clearDeals();
}
wrapped.setDeals(value);
return this;
}
@Override public Builder clearDeals() {
wrapped.__deals = _DEFAULT.get().__deals;
wrapped.is_default$deals = true;
wrapped._deals = _DEFAULT.get()._deals;
return this;
}
}
static private java.lang.ThreadLocal _DEFAULT = new java.lang.ThreadLocal() {
@Override protected NativeImpl initialValue() {
NativeImpl instance = new NativeImpl();
assert instance.isDefault();
return instance;
}
};
static public final long serialVersionUID = 2;
}
/** Returns a POJO builder instance with default values. */
static Builder newNativeImplBuilder() { return new NativeImpl.NativeImplBuilder(); }
/** Returns a POJO builder instance based on existing prototype Pmp. */
static Builder newNativeImplBuilder(open_rtb.Pmp> other) {
return newNativeImplBuilder()
.setPrivateAuction(other.getPrivateAuction())
.setDeals(other.getDeals());
}
/** Returns a POJO based on an instance of Pmp. */
static NativeImpl nativeImpl(open_rtb.Pmp> instance) {
if (instance instanceof NativeImpl) {
return (NativeImpl) instance;
} else {
return (NativeImpl) newNativeImplBuilder(instance).build();
}
}
static class Avro implements open_rtb.Pmp {
private byte[] binaryEncoding;
transient private open_rtb.PmpAvro wrapped;
transient private java.lang.Boolean is_default$private_auction;
transient private java.lang.Boolean is_default$deals;
transient private java.util.List> _deals;
private Avro(open_rtb.PmpAvro wrapped, byte[] binaryEncoding) {
this.wrapped = wrapped;
this.binaryEncoding = binaryEncoding;
}
/** Constructs a new Avro instance based on a message's binary encoding. Only use this if you know what you're doing. */
public Avro(byte[] binaryEncoding) { this(null, binaryEncoding); }
@Override public open_rtb.PmpAvro get() {
if (wrapped == null) {
try {
wrapped = decode(binaryEncoding);
} catch (java.io.IOException e) {
throw new java.io.UncheckedIOException(e);
}
}
return wrapped;
}
@Override public Builder newBuilder() {
return newAvroBuilder(get());
}
/** Returns an Avro binary encoding of this record. */
public byte[] toByteArray() {
return (byte[]) encoded().binaryEncoding.clone();
}
/** Returns the Avro binary encoding of this record wrapped in a read-only buffer. */
public java.nio.ByteBuffer toByteBuffer() {
return java.nio.ByteBuffer.wrap(encoded().binaryEncoding).asReadOnlyBuffer();
}
@Override public int getPrivateAuction() {
return get().private_auction;
}
@Override public boolean isDefaultPrivateAuction() {
if (is_default$private_auction == null) {
is_default$private_auction = 0 == getPrivateAuction();
}
return is_default$private_auction;
}
@Override public java.util.List> getDeals() {
if (_deals == null) {
_deals = java.util.Collections.unmodifiableList(get().deals.stream().map(open_rtb.Deal::avro).collect(java.util.stream.Collectors.toCollection(() -> new java.util.ArrayList>(get().deals.size()))));
}
return _deals;
}
@Override public boolean isDefaultDeals() {
if (is_default$deals == null) {
is_default$deals = getDeals().isEmpty();
}
return is_default$deals;
}
@Override public boolean equals(Object other) {
if (other == this) return true;
if (other == null && !(other instanceof Avro)) return false;
return get().equals(((Avro) other).get());
}
@Override public int hashCode() { return get().hashCode(); }
@Override public String toString() { return get().toString(); }
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
if (binaryEncoding == null) { encode(); }
out.defaultWriteObject();
}
public Avro encoded() {
if (binaryEncoding != null) {
try {
encode();
} catch (java.io.IOException e) {
throw new java.io.UncheckedIOException(e);
}
}
return this;
}
private void encode() throws java.io.IOException {
java.io.ByteArrayOutputStream stream = _ENCODER_STREAM.get();
org.apache.avro.io.BinaryEncoder encoder = _ENCODER.get();
stream.reset();
wrapped.encode(encoder);
encoder.flush();
binaryEncoding = stream.toByteArray();
}
static private open_rtb.PmpAvro decode(byte[] binaryEncoding) throws java.io.IOException {
open_rtb.PmpAvro instance = new open_rtb.PmpAvro();
org.apache.avro.io.BinaryDecoder decoder = org.apache.avro.io.DecoderFactory.get().binaryDecoder(binaryEncoding, _DECODER.get());
return instance.decode(decoder);
}
/** Decodes a Avro record. */
static public open_rtb.Pmp from(byte[] binaryEncoding) throws java.io.IOException {
return new Avro(decode(binaryEncoding), binaryEncoding);
}
static private java.lang.ThreadLocal _DECODER = new java.lang.ThreadLocal() {
@Override protected org.apache.avro.io.BinaryDecoder initialValue() { return org.apache.avro.io.DecoderFactory.get().binaryDecoder(new byte[0], null); }
};
static private java.lang.ThreadLocal _ENCODER_STREAM = new java.lang.ThreadLocal() {
@Override protected java.io.ByteArrayOutputStream initialValue() { return new java.io.ByteArrayOutputStream(); }
};
static private java.lang.ThreadLocal _ENCODER = new java.lang.ThreadLocal() {
@Override protected org.apache.avro.io.BinaryEncoder initialValue() { return org.apache.avro.io.EncoderFactory.get().binaryEncoder(_ENCODER_STREAM.get(), null); }
};
static private java.lang.ThreadLocal _DEFAULT = new java.lang.ThreadLocal() {
@Override protected Avro initialValue() { return new Avro(open_rtb.PmpAvro.newBuilder().build(), null); }
};
static public final long serialVersionUID = 2;
}
static class AvroBuilder implements Builder {
final private open_rtb.PmpAvro.Builder builder;
/** Only use this if you know what you are doing. */
public AvroBuilder(open_rtb.PmpAvro.Builder builder) { this.builder = builder; }
@Override public open_rtb.Pmp build() {
return new Avro(builder.build(), null);
}
@Override public Builder setPrivateAuction(int value) {
builder.setPrivateAuction(value);
return this;
}
@Override public Builder clearPrivateAuction() {
builder.clearPrivateAuction();
return this;
}
@Override public Builder setDeals(java.util.List> value) {
builder.setDeals(value.stream().map(open_rtb.Deal::avro).map(java.util.function.Supplier::get).collect(java.util.stream.Collectors.toCollection(() -> new org.apache.avro.generic.GenericData.Array<>(value.size(), open_rtb.PmpAvro.SCHEMA$.getFields().get(1).schema()))));
return this;
}
@Override public Builder clearDeals() {
builder.clearDeals();
return this;
}
}
/** Returns new Avro builder instance with default values. */
static Builder newAvroBuilder() {
return new AvroBuilder(open_rtb.PmpAvro.newBuilder());
}
/** Returns new Avro builder instance based on existing prototype. */
static Builder newAvroBuilder(open_rtb.PmpAvro other) {
return new AvroBuilder(open_rtb.PmpAvro.newBuilder(other));
}
/** Returns new Avro builder instance based on existing prototype builder. */
static Builder newAvroBuilder(open_rtb.PmpAvro.Builder other) {
return new AvroBuilder(open_rtb.PmpAvro.newBuilder(other));
}
/** Returns new Avro builder instance based on existing prototype Pmp. */
static Builder newAvroBuilder(open_rtb.Pmp> other) {
return newAvroBuilder()
.setPrivateAuction(other.getPrivateAuction())
.setDeals(other.getDeals());
}
/** Returns a wrapped Avro record based on an instance of Pmp. */
static Avro avro(open_rtb.Pmp> instance) {
if (instance instanceof Avro) {
return (Avro) instance;
} else {
return (Avro) newAvroBuilder(instance).build();
}
}
/** Wraps an existing Avro record. */
static Avro avro(open_rtb.PmpAvro wrapped) {
assert wrapped != null;
return new Avro(wrapped.freeze(), null);
}
/** Returns Avro record class. */
static java.lang.Class getAvroClass() {
return open_rtb.PmpAvro.class;
}
/** Returns Avro record schema. */
static org.apache.avro.Schema getAvroSchema() {
return open_rtb.PmpAvro.SCHEMA$;
}
static class Protobuf implements open_rtb.Pmp {
private byte[] binaryEncoding;
transient private open_rtb.OpenRtbProtobuf.Pmp wrapped;
transient private java.lang.Boolean is_default$private_auction;
transient private java.lang.Boolean is_default$deals;
transient private java.util.List> _deals;
private Protobuf(open_rtb.OpenRtbProtobuf.Pmp wrapped, byte[] binaryEncoding) {
this.wrapped = wrapped;
this.binaryEncoding = binaryEncoding;
}
/** Constructs a new Protobuf instance based on a message's binary encoding. Only use this if you know what you're doing. */
public Protobuf(byte[] binaryEncoding) { this(null, binaryEncoding); }
@Override public open_rtb.OpenRtbProtobuf.Pmp get() {
if (wrapped == null) {
try {
wrapped = open_rtb.OpenRtbProtobuf.Pmp.parseFrom(binaryEncoding);
} catch (java.io.IOException e) {
throw new java.io.UncheckedIOException(e);
}
}
return wrapped;
}
@Override public Builder newBuilder() {
return newProtobufBuilder(get());
}
@Override public int getPrivateAuction() {
return get().getPrivateAuction();
}
@Override public boolean isDefaultPrivateAuction() {
if (is_default$private_auction == null) {
is_default$private_auction = 0 == getPrivateAuction();
}
return is_default$private_auction;
}
@Override public java.util.List> getDeals() {
if (_deals == null) {
_deals = java.util.Collections.unmodifiableList(get().getDealsList().stream().map(open_rtb.Deal::protobuf).collect(java.util.stream.Collectors.toCollection(() -> new java.util.ArrayList>(get().getDealsCount()))));
}
return _deals;
}
@Override public boolean isDefaultDeals() {
if (is_default$deals == null) {
is_default$deals = getDeals().isEmpty();
}
return is_default$deals;
}
@Override public boolean equals(Object other) {
if (other == this) return true;
if (other == null && !(other instanceof Protobuf)) return false;
return get().equals(((Protobuf) other).get());
}
@Override public int hashCode() { return get().hashCode(); }
@Override public String toString() { return get().toString(); }
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
if (binaryEncoding == null) {
binaryEncoding = wrapped.toByteArray();
}
out.defaultWriteObject();
}
/** Decodes a Protobuf message. */
static public open_rtb.Pmp from(byte[] binaryEncoding) throws java.io.IOException {
return new Protobuf(open_rtb.OpenRtbProtobuf.Pmp.parseFrom(binaryEncoding), binaryEncoding);
}
static private java.lang.ThreadLocal _DEFAULT = new java.lang.ThreadLocal() {
@Override protected Protobuf initialValue() { return new Protobuf(open_rtb.OpenRtbProtobuf.Pmp.getDefaultInstance() , null); }
};
static public final long serialVersionUID = 2;
}
static class ProtobufBuilder implements Builder {
final private open_rtb.OpenRtbProtobuf.Pmp.Builder builder;
/** Only use this if you know what you are doing. */
public ProtobufBuilder(open_rtb.OpenRtbProtobuf.Pmp.Builder builder) { this.builder = builder; }
@Override public open_rtb.Pmp build() {
return new Protobuf(builder.build(), null);
}
@Override public Builder setPrivateAuction(int value) {
if (!(0 == value)) {
builder.setPrivateAuction(value);
}
return this;
}
@Override public Builder clearPrivateAuction() {
builder.clearPrivateAuction();
return this;
}
@Override public Builder setDeals(java.util.List> value) {
if (!(value.isEmpty())) {
builder.addAllDeals(value.stream().map(open_rtb.Deal::protobuf).map(java.util.function.Supplier::get).collect(java.util.stream.Collectors.toCollection(() -> new java.util.ArrayList(value.size()))));
}
return this;
}
@Override public Builder clearDeals() {
builder.clearDeals();
return this;
}
}
/** Returns new Protobuf builder instance with default values. */
static Builder newProtobufBuilder() {
return new ProtobufBuilder(open_rtb.OpenRtbProtobuf.Pmp.newBuilder());
}
/** Returns new Protobuf builder instance based on existing prototype. */
static Builder newProtobufBuilder(open_rtb.OpenRtbProtobuf.Pmp other) {
return new ProtobufBuilder(open_rtb.OpenRtbProtobuf.Pmp.newBuilder(other));
}
/** Returns new Protobuf builder instance based on existing prototype Pmp. */
static Builder newProtobufBuilder(open_rtb.Pmp> other) {
return newProtobufBuilder()
.setPrivateAuction(other.getPrivateAuction())
.setDeals(other.getDeals());
}
/** Returns a wrapped Protobuf message based on an instance of Pmp. */
static Protobuf protobuf(open_rtb.Pmp> instance) {
if (instance instanceof Protobuf) {
return (Protobuf) instance;
}
return (Protobuf) newProtobufBuilder(instance).build();
}
/** Wraps an existing Protobuf message. */
static Protobuf protobuf(open_rtb.OpenRtbProtobuf.Pmp wrapped) {
assert wrapped != null;
return new Protobuf(wrapped, null);
}
/** Returns Protobuf class for this struct. */
static java.lang.Class getProtobufClass() {
return open_rtb.OpenRtbProtobuf.Pmp.class;
}
/** Returns Protobuf protocol class for this struct. */
static java.lang.Class getProtobufProtocolClass() {
return com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.class;
}
/** Returns Protobuf descriptor for this struct. */
static com.google.protobuf.Descriptors.Descriptor getProtobufDescriptor() {
return open_rtb.OpenRtbProtobuf.Pmp.getDescriptor();
}
/** Returns Protobuf protocol descriptor for this struct. */
static com.google.protobuf.Descriptors.FileDescriptor getProtobufProtocolDescriptor() {
return com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.getDescriptor();
}
static class Thrift implements open_rtb.Pmp {
private open_rtb.PmpThrift wrapped;
transient private java.lang.Boolean is_default$private_auction;
transient private java.lang.Boolean is_default$deals;
transient private java.util.List> _deals;
/** Wraps an existing instance. Only use this if you know what you are doing. */
public Thrift(open_rtb.PmpThrift wrapped) { this.wrapped = wrapped; }
/** Create a new wrapper. */
public Thrift() { this(new open_rtb.PmpThrift()); }
@Override public open_rtb.PmpThrift get() { return wrapped; }
@Override public Builder newBuilder() {
return newThriftBuilder(get());
}
@Override public int getPrivateAuction() {
return wrapped.getPrivate_auction();
}
@Override public boolean isDefaultPrivateAuction() {
if (is_default$private_auction == null) {
is_default$private_auction = 0 == getPrivateAuction();
}
return is_default$private_auction;
}
@Override public java.util.List> getDeals() {
if (_deals == null) {
_deals = java.util.Optional.ofNullable(wrapped.getDeals()).orElseGet(java.util.Collections::emptyList).stream().map(open_rtb.Deal::thrift).collect(java.util.stream.Collectors.toCollection(() -> new java.util.ArrayList>()));
}
return _deals;
}
@Override public boolean isDefaultDeals() {
if (is_default$deals == null) {
is_default$deals = getDeals().isEmpty();
}
return is_default$deals;
}
@Override public boolean equals(Object other) {
if (other == this) return true;
if (other == null || !(other instanceof Thrift)) return false;
return wrapped.equals(((Thrift) other).wrapped);
}
@Override public int hashCode() { return wrapped.hashCode(); }
@Override public String toString() { return wrapped.toString(); }
static private java.lang.ThreadLocal _DEFAULT = new java.lang.ThreadLocal() {
@Override protected Thrift initialValue() { return new Thrift(); }
};
static public final long serialVersionUID = 2;
}
static class ThriftBuilder implements Builder {
final private open_rtb.PmpThrift builder;
/** Only use this if you know what you are doing. */
public ThriftBuilder(open_rtb.PmpThrift builder) { this.builder = builder; }
@Override public open_rtb.Pmp build() {
return new Thrift((open_rtb.PmpThrift) builder.deepCopy());
}
@Override public Builder setPrivateAuction(int value) {
if (!(0 == value)) {
builder.setPrivate_auction((byte) value);
}
return this;
}
@Override public Builder clearPrivateAuction() {
builder.unsetPrivate_auction();
return this;
}
@Override public Builder setDeals(java.util.List> value) {
if (!(value.isEmpty())) {
builder.setDeals(value.stream().map(open_rtb.Deal::thrift).map(java.util.function.Supplier::get).collect(java.util.stream.Collectors.toCollection(() -> new java.util.ArrayList<>(value.size()))));
}
return this;
}
@Override public Builder clearDeals() {
builder.unsetDeals();
return this;
}
}
/** Returns new Thrift builder instance with default values. */
static Builder newThriftBuilder() {
return new ThriftBuilder(new open_rtb.PmpThrift());
}
/** Returns new Thrift builder instance based on existing prototype. */
static Builder newThriftBuilder(open_rtb.PmpThrift other) {
return new ThriftBuilder((open_rtb.PmpThrift) other.deepCopy());
}
/** Returns new Thrift builder instance based on existing prototype Pmp. */
static Builder newThriftBuilder(open_rtb.Pmp> other) {
return newThriftBuilder()
.setPrivateAuction(other.getPrivateAuction())
.setDeals(other.getDeals());
}
/** Returns a wrapped Thrift struct based on an instance of Pmp. */
static Thrift thrift(open_rtb.Pmp> instance) {
if (instance instanceof Thrift) {
return (Thrift) instance;
}
return (Thrift) newThriftBuilder(instance).build();
}
/** Creates a new wrapped Thrift struct copied from an existing instance. */
@SuppressWarnings("all")
static Thrift thrift(open_rtb.PmpThrift instance) {
return new Thrift((open_rtb.PmpThrift) instance.deepCopy());
}
/** Returns Thrift class for this struct. */
static java.lang.Class getThriftClass() {
return open_rtb.PmpThrift.class;
}
/** Returns Thrift metadata map for this struct. */
static java.util.Map getThriftMetadataMap() {
return open_rtb.PmpThrift.metaDataMap;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy