All Downloads are FREE. Search and download functionalities are using the official Maven repository.

open_rtb.Regulations Maven / Gradle / Ivy

There is a newer version: 3.1.2
Show newest version
/**
 * Autogenerated by Avro
 * 
 * DO NOT EDIT DIRECTLY
 */

package open_rtb;

/** 3.3.15 Regulations Object
The “regs” object contains any legal, governmental, or industry regulations that apply to the request.
The first regulation added signal whether or not the request falls under the United States Federal Trade Commission’s regulations for the United States Children’s Online Privacy Protection Act (“COPPA”). See the COPPA appendix for details.
The regs object itself and all of its parameters are optional, so default values are not provided. If an optional parameter is not specified, it should be considered unknown. */
public interface Regulations
  extends java.util.function.Supplier,
          java.lang.Comparable>,
          java.io.Serializable {

  /** True if all fields are set to default values. */
  default boolean isDefault() {
    return
      isDefaultCoppa();
  }

  /** Returns underlying object. */
  T get();

  /** Creates a new builder based on this object. */
  Builder newBuilder();

  /** Flag indicating whether or not this request falls under the COPPA regulations established by the USA FTC, where 0 = no, 1 = yes. */
  int getCoppa();

  boolean isDefaultCoppa();

  public interface Builder {

    Regulations build();

    Builder setCoppa(int value);

    Builder clearCoppa();
  }


  static class Comparator implements java.util.Comparator>, java.io.Serializable {

    @Override public int compare(open_rtb.Regulations a, open_rtb.Regulations b) {
      int _cmp;
      if (0 != (_cmp = compareCoppa(a, b))) return _cmp;
      return 0;
    }

    static private int compareCoppa (open_rtb.Regulations a, open_rtb.Regulations b) {
      final java.lang.Integer fa = a.getCoppa();
      final java.lang.Integer fb = b.getCoppa();
      return java.lang.Integer.compareUnsigned(fa, fb);
    }

    static private final Comparator INSTANCE = new Comparator();

    static public final long serialVersionUID = 1;
  }

  /** Returns comparator instance for Regulations objects. */
  static java.util.Comparator> getComparator() {
    return Comparator.INSTANCE;
  }

  @Override default int compareTo(open_rtb.Regulations other) {
    return getComparator().compare(this, other);
  }

  static class NativeImpl implements open_rtb.Regulations {

    transient private java.lang.String json;
    private int __coppa;
    transient private java.lang.Boolean is_default$coppa;

    private NativeImpl() {
      __coppa = 0;
      is_default$coppa = java.lang.Boolean.TRUE;
      json = "{}";
    }

    private NativeImpl(NativeImpl other) {
      setCoppa(other.getCoppa());
      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 (!isDefaultCoppa()) {
        sb.append((0 == sb.length()) ? "{\"coppa\": " : ", \"coppa\": ")
          .append(__coppa);
      }
      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 getCoppa() {
      return __coppa;
    }

    @Override public boolean isDefaultCoppa() {
      if (null == is_default$coppa) {
        is_default$coppa = 0 == getCoppa();
      }
      return is_default$coppa;
    }

    private void setCoppa(int value) {
      this.__coppa = value;
      this.is_default$coppa = null;
      this.json = null;
    }

    static class NativeImplBuilder implements Builder {

      private NativeImpl wrapped = new NativeImpl();

      @Override public open_rtb.Regulations build() {
        return new NativeImpl(wrapped);
      }

      @Override public Builder setCoppa(int value) {
        if (0 == value) {
          return clearCoppa();
        }
        wrapped.setCoppa(value);
        return this;
      }

      @Override public Builder clearCoppa() {
        wrapped.__coppa = _DEFAULT.get().__coppa;
        wrapped.is_default$coppa = true;
        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 = 1;
  }

  /** Returns a POJO builder instance with default values. */
  static Builder newNativeImplBuilder() { return new NativeImpl.NativeImplBuilder(); }

  /** Returns a POJO builder instance based on existing prototype Regulations. */
  static Builder newNativeImplBuilder(open_rtb.Regulations other) {
    return newNativeImplBuilder()
      .setCoppa(other.getCoppa());
  }

  /** Returns a POJO based on an instance of Regulations. */
  static NativeImpl nativeImpl(open_rtb.Regulations instance) {
    if (instance instanceof NativeImpl) {
      return (NativeImpl) instance;
    } else {
      return (NativeImpl) newNativeImplBuilder(instance).build();
    }
  }

  static class Avro implements open_rtb.Regulations {

    private byte[] binaryEncoding;
    transient private open_rtb.RegulationsAvro wrapped;
    transient private java.lang.Boolean is_default$coppa;

    private Avro(open_rtb.RegulationsAvro 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.RegulationsAvro 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 getCoppa() {
      return get().coppa;
    }

    @Override public boolean isDefaultCoppa() {
      if (is_default$coppa == null) {
        is_default$coppa = 0 == getCoppa();
      }
      return is_default$coppa;
    }

    @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.RegulationsAvro decode(byte[] binaryEncoding) throws java.io.IOException {
      open_rtb.RegulationsAvro instance = new open_rtb.RegulationsAvro();
      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.Regulations 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.RegulationsAvro.newBuilder().build(), null); }
    };

    static public final long serialVersionUID = 1;
  }

  static class AvroBuilder implements Builder {

    final private open_rtb.RegulationsAvro.Builder builder;

    /** Only use this if you know what you are doing. */
    public AvroBuilder(open_rtb.RegulationsAvro.Builder builder) { this.builder = builder; }

    @Override public open_rtb.Regulations build() {
      return new Avro(builder.build(), null);
    }

    @Override public Builder setCoppa(int value) {
      builder.setCoppa(value);
      return this;
    }

    @Override public Builder clearCoppa() {
      builder.clearCoppa();
      return this;
    }
  }

  /** Returns new Avro builder instance with default values. */
  static Builder newAvroBuilder() {
    return new AvroBuilder(open_rtb.RegulationsAvro.newBuilder());
  }

  /** Returns new Avro builder instance based on existing prototype. */
  static Builder newAvroBuilder(open_rtb.RegulationsAvro other) {
    return new AvroBuilder(open_rtb.RegulationsAvro.newBuilder(other));
  }

  /** Returns new Avro builder instance based on existing prototype builder. */
  static Builder newAvroBuilder(open_rtb.RegulationsAvro.Builder other) {
    return new AvroBuilder(open_rtb.RegulationsAvro.newBuilder(other));
  }

  /** Returns new Avro builder instance based on existing prototype Regulations. */
  static Builder newAvroBuilder(open_rtb.Regulations other) {
    return newAvroBuilder()
      .setCoppa(other.getCoppa());
  }

  /** Returns a wrapped Avro record based on an instance of Regulations. */
  static Avro avro(open_rtb.Regulations instance) {
    if (instance instanceof Avro) {
      return (Avro) instance;
    } else {
      return (Avro) newAvroBuilder(instance).build();
    }
  }

  /** Wraps an existing Avro record. */
  static Avro avro(open_rtb.RegulationsAvro wrapped) {
    assert wrapped != null;
    return new Avro(wrapped.freeze(), null);
  }

  /** Returns Avro record class. */
  static java.lang.Class getAvroClass() {
    return open_rtb.RegulationsAvro.class;
  }

  /** Returns Avro record schema. */
  static org.apache.avro.Schema getAvroSchema() {
    return open_rtb.RegulationsAvro.SCHEMA$;
  }

  static class Protobuf implements open_rtb.Regulations {

    private byte[] binaryEncoding;
    transient private open_rtb.OpenRtbProtobuf.Regulations wrapped;
    transient private java.lang.Boolean is_default$coppa;

    private Protobuf(open_rtb.OpenRtbProtobuf.Regulations 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.Regulations get() {
      if (wrapped == null) {
        try {
          wrapped = open_rtb.OpenRtbProtobuf.Regulations.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 getCoppa() {
      return get().getCoppa();
    }

    @Override public boolean isDefaultCoppa() {
      if (is_default$coppa == null) {
        is_default$coppa = 0 == getCoppa();
      }
      return is_default$coppa;
    }

    @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.Regulations from(byte[] binaryEncoding) throws java.io.IOException {
      return new Protobuf(open_rtb.OpenRtbProtobuf.Regulations.parseFrom(binaryEncoding), binaryEncoding);
    }

    static private java.lang.ThreadLocal _DEFAULT = new java.lang.ThreadLocal() {
      @Override protected Protobuf initialValue() { return new Protobuf(open_rtb.OpenRtbProtobuf.Regulations.getDefaultInstance() , null); }
    };

    static public final long serialVersionUID = 1;
  }

  static class ProtobufBuilder implements Builder {

    final private open_rtb.OpenRtbProtobuf.Regulations.Builder builder;

    /** Only use this if you know what you are doing. */
    public ProtobufBuilder(open_rtb.OpenRtbProtobuf.Regulations.Builder builder) { this.builder = builder; }

    @Override public open_rtb.Regulations build() {
      return new Protobuf(builder.build(), null);
    }

    @Override public Builder setCoppa(int value) {
      if (!(0 == value)) {
        builder.setCoppa(value);
      }
      return this;
    }

    @Override public Builder clearCoppa() {
      builder.clearCoppa();
      return this;
    }
  }

  /** Returns new Protobuf builder instance with default values. */
  static Builder newProtobufBuilder() {
    return new ProtobufBuilder(open_rtb.OpenRtbProtobuf.Regulations.newBuilder());
  }

  /** Returns new Protobuf builder instance based on existing prototype. */
  static Builder newProtobufBuilder(open_rtb.OpenRtbProtobuf.Regulations other) {
    return new ProtobufBuilder(open_rtb.OpenRtbProtobuf.Regulations.newBuilder(other));
  }

  /** Returns new Protobuf builder instance based on existing prototype Regulations. */
  static Builder newProtobufBuilder(open_rtb.Regulations other) {
    return newProtobufBuilder()
      .setCoppa(other.getCoppa());
  }

  /** Returns a wrapped Protobuf message based on an instance of Regulations. */
  static Protobuf protobuf(open_rtb.Regulations instance) {
    if (instance instanceof Protobuf) {
      return (Protobuf) instance;
    }
    return (Protobuf) newProtobufBuilder(instance).build();
  }

  /** Wraps an existing Protobuf message. */
  static Protobuf protobuf(open_rtb.OpenRtbProtobuf.Regulations wrapped) {
    assert wrapped != null;
    return new Protobuf(wrapped, null);
  }

  /** Returns Protobuf class for this struct. */
  static java.lang.Class getProtobufClass() {
    return open_rtb.OpenRtbProtobuf.Regulations.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.Regulations.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.Regulations {

    private open_rtb.RegulationsThrift wrapped;
    transient private java.lang.Boolean is_default$coppa;

    /** Wraps an existing instance. Only use this if you know what you are doing. */
    public Thrift(open_rtb.RegulationsThrift wrapped) { this.wrapped = wrapped; }

    /** Create a new wrapper. */
    public Thrift() { this(new open_rtb.RegulationsThrift()); }

    @Override public open_rtb.RegulationsThrift get() { return wrapped; }

    @Override public Builder newBuilder() {
      return newThriftBuilder(get());
    }

    @Override public int getCoppa() {
      return wrapped.getCoppa();
    }

    @Override public boolean isDefaultCoppa() {
      if (is_default$coppa == null) {
        is_default$coppa = 0 == getCoppa();
      }
      return is_default$coppa;
    }

    @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 = 1;
  }

  static class ThriftBuilder implements Builder {

    final private open_rtb.RegulationsThrift builder;

    /** Only use this if you know what you are doing. */
    public ThriftBuilder(open_rtb.RegulationsThrift builder) { this.builder = builder; }

    @Override public open_rtb.Regulations build() {
      return new Thrift((open_rtb.RegulationsThrift) builder.deepCopy());
    }

    @Override public Builder setCoppa(int value) {
      if (!(0 == value)) {
        builder.setCoppa((byte) value);
      }
      return this;
    }

    @Override public Builder clearCoppa() {
      builder.unsetCoppa();
      return this;
    }
  }

  /** Returns new Thrift builder instance with default values. */
  static Builder newThriftBuilder() {
    return new ThriftBuilder(new open_rtb.RegulationsThrift());
  }

  /** Returns new Thrift builder instance based on existing prototype. */
  static Builder newThriftBuilder(open_rtb.RegulationsThrift other) {
    return new ThriftBuilder((open_rtb.RegulationsThrift) other.deepCopy());
  }

  /** Returns new Thrift builder instance based on existing prototype Regulations. */
  static Builder newThriftBuilder(open_rtb.Regulations other) {
    return newThriftBuilder()
      .setCoppa(other.getCoppa());
  }

  /** Returns a wrapped Thrift struct based on an instance of Regulations. */
  static Thrift thrift(open_rtb.Regulations 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.RegulationsThrift instance) {
    return new Thrift((open_rtb.RegulationsThrift) instance.deepCopy());
  }

  /** Returns Thrift class for this struct. */
  static java.lang.Class getThriftClass() {
    return open_rtb.RegulationsThrift.class;
  }

  /** Returns Thrift metadata map for this struct. */
  static java.util.Map getThriftMetadataMap() {
    return open_rtb.RegulationsThrift.metaDataMap;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy