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

com.adgear.anoa.test.ad_exchange.LogEvent Maven / Gradle / Ivy

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

package com.adgear.anoa.test.ad_exchange;

/** Log event for real-time bidding ad exchange client. */
public interface LogEvent
  extends java.util.function.Supplier,
          java.lang.Comparable>,
          java.io.Serializable {

  /** True if all fields are set to default values. */
  default boolean isDefault() {
    return
      isDefaultUuid() &&
      isDefaultTimestamp() &&
      isDefaultType() &&
      isDefaultRequest() &&
      isDefaultResponse() &&
      isDefaultProperties();
  }

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

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

  /** Log event unique identifier. */
  java.util.function.Supplier getUuid();

  boolean isDefaultUuid();

  /** Log event timestamp, in milliseconds from epoch. */
  long getTimestamp();

  boolean isDefaultTimestamp();

  /** Log event type. */
  com.adgear.anoa.test.ad_exchange.LogEventType getType();

  boolean isDefaultType();

  open_rtb.BidRequest getRequest();

  boolean isDefaultRequest();

  /** Bid response submitted to the real-time bidding ad exchange. */
  open_rtb.BidResponse getResponse();

  boolean isDefaultResponse();

  /** Log event custom properties. */
  java.util.SortedMap getProperties();

  boolean isDefaultProperties();

  public interface Builder {

    LogEvent build();

    Builder setUuid(java.util.function.Supplier value);

    Builder clearUuid();

    Builder setTimestamp(long value);

    Builder clearTimestamp();

    Builder setType(com.adgear.anoa.test.ad_exchange.LogEventType value);

    Builder clearType();

    Builder setRequest(open_rtb.BidRequest value);

    Builder clearRequest();

    Builder setResponse(open_rtb.BidResponse value);

    Builder clearResponse();

    Builder setProperties(java.util.Map value);

    Builder clearProperties();
  }


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

    @Override public int compare(com.adgear.anoa.test.ad_exchange.LogEvent a, com.adgear.anoa.test.ad_exchange.LogEvent b) {
      int _cmp;
      if (0 != (_cmp = compareUuid(a, b))) return _cmp;
      if (0 != (_cmp = compareTimestamp(a, b))) return _cmp;
      if (0 != (_cmp = compareType(a, b))) return _cmp;
      if (0 != (_cmp = compareRequest(a, b))) return _cmp;
      if (0 != (_cmp = compareResponse(a, b))) return _cmp;
      if (0 != (_cmp = compareProperties(a, b))) return _cmp;
      return 0;
    }

    static private int compareUuid (com.adgear.anoa.test.ad_exchange.LogEvent a, com.adgear.anoa.test.ad_exchange.LogEvent b) {
      final java.util.function.Supplier fa = a.getUuid();
      final java.util.function.Supplier fb = b.getUuid();
      return java.nio.ByteBuffer.wrap(fa.get()).compareTo(java.nio.ByteBuffer.wrap(fb.get()));
    }

    static private int compareTimestamp (com.adgear.anoa.test.ad_exchange.LogEvent a, com.adgear.anoa.test.ad_exchange.LogEvent b) {
      final java.lang.Long fa = a.getTimestamp();
      final java.lang.Long fb = b.getTimestamp();
      return java.lang.Long.compareUnsigned(fa, fb);
    }

    static private int compareType (com.adgear.anoa.test.ad_exchange.LogEvent a, com.adgear.anoa.test.ad_exchange.LogEvent b) {
      final com.adgear.anoa.test.ad_exchange.LogEventType fa = a.getType();
      final com.adgear.anoa.test.ad_exchange.LogEventType fb = b.getType();
      return fa.getOrdinal() - fb.getOrdinal();
    }

    static private int compareRequest (com.adgear.anoa.test.ad_exchange.LogEvent a, com.adgear.anoa.test.ad_exchange.LogEvent b) {
      final open_rtb.BidRequest fa = a.getRequest();
      final open_rtb.BidRequest fb = b.getRequest();
      return fa.compareTo(fb);
    }

    static private int compareResponse (com.adgear.anoa.test.ad_exchange.LogEvent a, com.adgear.anoa.test.ad_exchange.LogEvent b) {
      final open_rtb.BidResponse fa = a.getResponse();
      final open_rtb.BidResponse fb = b.getResponse();
      return fa.compareTo(fb);
    }

    static private int compareProperties (com.adgear.anoa.test.ad_exchange.LogEvent a, com.adgear.anoa.test.ad_exchange.LogEvent b) {
      final java.util.SortedMap fa = a.getProperties();
      final java.util.SortedMap fb = b.getProperties();
      int _cmp = 0; java.util.Iterator> a_it5 = fa.entrySet().iterator(); java.util.Iterator> b_it5 = fb.entrySet().iterator(); while (a_it5.hasNext() && b_it5.hasNext()) { java.util.Map.Entry _ae5 = a_it5.next(); java.util.Map.Entry _be5 = b_it5.next(); if (0 != (_cmp = _ae5.getKey().compareTo(_be5.getKey()))) return _cmp; if (0 != (_cmp = _ae5.getValue().compareTo(_be5.getValue()))) return _cmp; } if (a_it5.hasNext()) return 1; if (b_it5.hasNext()) return -1; return 0;
    }

    static private final Comparator INSTANCE = new Comparator();

    static public final long serialVersionUID = 6;
  }

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

  @Override default int compareTo(com.adgear.anoa.test.ad_exchange.LogEvent other) {
    return getComparator().compare(this, other);
  }

  static class NativeImpl implements com.adgear.anoa.test.ad_exchange.LogEvent {

    transient private java.lang.String json;
    private byte[] __uuid;
    transient private java.lang.Boolean is_default$uuid;
    transient private java.util.function.Supplier _uuid;
    private long __timestamp;
    transient private java.lang.Boolean is_default$timestamp;
    private com.adgear.anoa.test.ad_exchange.LogEventType __type;
    transient private java.lang.Boolean is_default$type;
    private open_rtb.BidRequest __request;
    transient private java.lang.Boolean is_default$request;
    private open_rtb.BidResponse __response;
    transient private java.lang.Boolean is_default$response;
    private java.util.SortedMap __properties;
    transient private java.lang.Boolean is_default$properties;
    transient private java.util.SortedMap _properties;

    private NativeImpl() {
      __uuid = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes();
      is_default$uuid = java.lang.Boolean.TRUE;
      __timestamp = 0L;
      is_default$timestamp = java.lang.Boolean.TRUE;
      __type = com.adgear.anoa.test.ad_exchange.LogEventType.nativeImpl(0);
      is_default$type = java.lang.Boolean.TRUE;
      __request = open_rtb.BidRequest.newNativeImplBuilder().build();
      is_default$request = java.lang.Boolean.TRUE;
      __response = open_rtb.BidResponse.newNativeImplBuilder().build();
      is_default$response = java.lang.Boolean.TRUE;
      __properties = java.util.Collections.emptySortedMap();
      is_default$properties = java.lang.Boolean.TRUE;
      json = "{}";
    }

    private NativeImpl(NativeImpl other) {
      setUuid(other.getUuid());
      setTimestamp(other.getTimestamp());
      setType(other.getType());
      setRequest(other.getRequest());
      setResponse(other.getResponse());
      setProperties(other.getProperties());
      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 (!isDefaultUuid()) {
        sb.append((0 == sb.length()) ? "{\"uuid\": " : ", \"uuid\": ")
          .append("\"" + java.util.Base64.getEncoder().encodeToString(__uuid) + '\"');
      }
      if (!isDefaultTimestamp()) {
        sb.append((0 == sb.length()) ? "{\"timestamp\": " : ", \"timestamp\": ")
          .append(__timestamp);
      }
      if (!isDefaultType()) {
        sb.append((0 == sb.length()) ? "{\"type\": " : ", \"type\": ")
          .append(__type);
      }
      if (!isDefaultRequest()) {
        sb.append((0 == sb.length()) ? "{\"request\": " : ", \"request\": ")
          .append(__request);
      }
      if (!isDefaultResponse()) {
        sb.append((0 == sb.length()) ? "{\"response\": " : ", \"response\": ")
          .append(__response);
      }
      if (!isDefaultProperties()) {
        sb.append((0 == sb.length()) ? "{\"properties\": " : ", \"properties\": ")
          .append(__properties.entrySet().stream().map(e -> "\"" + e.getKey() + "\": " + '\"' + e.getValue().replace("\"","\\\"") + '\"').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 java.util.function.Supplier getUuid() {
      if (null == _uuid) {
        _uuid = (java.util.function.Supplier) __uuid::clone;
      }
      return _uuid;
    }

    @Override public boolean isDefaultUuid() {
      if (null == is_default$uuid) {
        is_default$uuid = java.util.Arrays.equals(getUuid().get(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes());
      }
      return is_default$uuid;
    }

    private void setUuid(java.util.function.Supplier value) {
      this.__uuid = value.get().clone();
      this.is_default$uuid = null;
      this.json = null;
      this._uuid = null;
    }

    @Override public long getTimestamp() {
      return __timestamp;
    }

    @Override public boolean isDefaultTimestamp() {
      if (null == is_default$timestamp) {
        is_default$timestamp = 0 == getTimestamp();
      }
      return is_default$timestamp;
    }

    private void setTimestamp(long value) {
      this.__timestamp = value;
      this.is_default$timestamp = null;
      this.json = null;
    }

    @Override public com.adgear.anoa.test.ad_exchange.LogEventType getType() {
      return __type;
    }

    @Override public boolean isDefaultType() {
      if (null == is_default$type) {
        is_default$type = getType().getOrdinal() == 0;
      }
      return is_default$type;
    }

    private void setType(com.adgear.anoa.test.ad_exchange.LogEventType value) {
      this.__type = com.adgear.anoa.test.ad_exchange.LogEventType.nativeImpl(value);
      this.is_default$type = null;
      this.json = null;
    }

    @Override public open_rtb.BidRequest getRequest() {
      return __request;
    }

    @Override public boolean isDefaultRequest() {
      if (null == is_default$request) {
        is_default$request = getRequest().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.NativeImpl._DEFAULT.get().getRequest().get());
      }
      return is_default$request;
    }

    private void setRequest(open_rtb.BidRequest value) {
      this.__request = open_rtb.BidRequest.nativeImpl(value);
      this.is_default$request = null;
      this.json = null;
    }

    @Override public open_rtb.BidResponse getResponse() {
      return __response;
    }

    @Override public boolean isDefaultResponse() {
      if (null == is_default$response) {
        is_default$response = getResponse().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.NativeImpl._DEFAULT.get().getResponse().get());
      }
      return is_default$response;
    }

    private void setResponse(open_rtb.BidResponse value) {
      this.__response = open_rtb.BidResponse.nativeImpl(value);
      this.is_default$response = null;
      this.json = null;
    }

    @Override public java.util.SortedMap getProperties() {
      if (null == _properties) {
        _properties = java.util.Collections.unmodifiableSortedMap(__properties);
      }
      return _properties;
    }

    @Override public boolean isDefaultProperties() {
      if (null == is_default$properties) {
        is_default$properties = getProperties().isEmpty();
      }
      return is_default$properties;
    }

    private void setProperties(java.util.Map value) {
      this.__properties = value.entrySet().stream().collect(java.util.stream.Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (u,v) -> {throw new java.lang.IllegalStateException("Duplicate key " + u); }, () -> new java.util.TreeMap<>()));
      this.is_default$properties = null;
      this.json = null;
      this._properties = null;
    }

    static class NativeImplBuilder implements Builder {

      private NativeImpl wrapped = new NativeImpl();

      @Override public com.adgear.anoa.test.ad_exchange.LogEvent build() {
        return new NativeImpl(wrapped);
      }

      @Override public Builder setUuid(java.util.function.Supplier value) {
        if (java.util.Arrays.equals(value.get(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes())) {
          return clearUuid();
        }
        wrapped.setUuid(value);
        return this;
      }

      @Override public Builder clearUuid() {
        wrapped.__uuid = _DEFAULT.get().__uuid;
        wrapped.is_default$uuid = true;
        wrapped._uuid = _DEFAULT.get()._uuid;
        return this;
      }

      @Override public Builder setTimestamp(long value) {
        if (0 == value) {
          return clearTimestamp();
        }
        wrapped.setTimestamp(value);
        return this;
      }

      @Override public Builder clearTimestamp() {
        wrapped.__timestamp = _DEFAULT.get().__timestamp;
        wrapped.is_default$timestamp = true;
        return this;
      }

      @Override public Builder setType(com.adgear.anoa.test.ad_exchange.LogEventType value) {
        if (value.getOrdinal() == 0) {
          return clearType();
        }
        wrapped.setType(value);
        return this;
      }

      @Override public Builder clearType() {
        wrapped.__type = _DEFAULT.get().__type;
        wrapped.is_default$type = true;
        return this;
      }

      @Override public Builder setRequest(open_rtb.BidRequest value) {
        if (value.get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.NativeImpl._DEFAULT.get().getRequest().get())) {
          return clearRequest();
        }
        wrapped.setRequest(value);
        return this;
      }

      @Override public Builder clearRequest() {
        wrapped.__request = _DEFAULT.get().__request;
        wrapped.is_default$request = true;
        return this;
      }

      @Override public Builder setResponse(open_rtb.BidResponse value) {
        if (value.get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.NativeImpl._DEFAULT.get().getResponse().get())) {
          return clearResponse();
        }
        wrapped.setResponse(value);
        return this;
      }

      @Override public Builder clearResponse() {
        wrapped.__response = _DEFAULT.get().__response;
        wrapped.is_default$response = true;
        return this;
      }

      @Override public Builder setProperties(java.util.Map value) {
        if (value.isEmpty()) {
          return clearProperties();
        }
        wrapped.setProperties(value);
        return this;
      }

      @Override public Builder clearProperties() {
        wrapped.__properties = _DEFAULT.get().__properties;
        wrapped.is_default$properties = true;
        wrapped._properties = _DEFAULT.get()._properties;
        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 = 6;
  }

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

  /** Returns a POJO builder instance based on existing prototype LogEvent. */
  static Builder newNativeImplBuilder(com.adgear.anoa.test.ad_exchange.LogEvent other) {
    return newNativeImplBuilder()
      .setUuid(other.getUuid())
      .setTimestamp(other.getTimestamp())
      .setType(other.getType())
      .setRequest(other.getRequest())
      .setResponse(other.getResponse())
      .setProperties(other.getProperties());
  }

  /** Returns a POJO based on an instance of LogEvent. */
  static NativeImpl nativeImpl(com.adgear.anoa.test.ad_exchange.LogEvent instance) {
    if (instance instanceof NativeImpl) {
      return (NativeImpl) instance;
    } else {
      return (NativeImpl) newNativeImplBuilder(instance).build();
    }
  }

  static class Avro implements com.adgear.anoa.test.ad_exchange.LogEvent {

    private byte[] binaryEncoding;
    transient private com.adgear.anoa.test.ad_exchange.LogEventAvro wrapped;
    transient private java.lang.Boolean is_default$uuid;
    transient private java.util.function.Supplier _uuid;
    transient private java.lang.Boolean is_default$timestamp;
    transient private java.lang.Boolean is_default$type;
    transient private com.adgear.anoa.test.ad_exchange.LogEventType _type;
    transient private java.lang.Boolean is_default$request;
    transient private open_rtb.BidRequest _request;
    transient private java.lang.Boolean is_default$response;
    transient private open_rtb.BidResponse _response;
    transient private java.lang.Boolean is_default$properties;
    transient private java.util.SortedMap _properties;

    private Avro(com.adgear.anoa.test.ad_exchange.LogEventAvro 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 com.adgear.anoa.test.ad_exchange.LogEventAvro 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 java.util.function.Supplier getUuid() {
      if (_uuid == null) {
        _uuid = java.util.Optional.of(get().uuid).map(bb -> {byte[] b = new byte[bb.remaining()]; bb.asReadOnlyBuffer().get(b); return (java.util.function.Supplier)(b::clone);}).get();
      }
      return _uuid;
    }

    @Override public boolean isDefaultUuid() {
      if (is_default$uuid == null) {
        is_default$uuid = java.util.Arrays.equals(getUuid().get(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes());
      }
      return is_default$uuid;
    }

    @Override public long getTimestamp() {
      return get().timestamp;
    }

    @Override public boolean isDefaultTimestamp() {
      if (is_default$timestamp == null) {
        is_default$timestamp = 0 == getTimestamp();
      }
      return is_default$timestamp;
    }

    @Override public com.adgear.anoa.test.ad_exchange.LogEventType getType() {
      if (_type == null) {
        _type = com.adgear.anoa.test.ad_exchange.LogEventType.avro(get().type);
      }
      return _type;
    }

    @Override public boolean isDefaultType() {
      if (is_default$type == null) {
        is_default$type = getType().getOrdinal() == 0;
      }
      return is_default$type;
    }

    @Override public open_rtb.BidRequest getRequest() {
      if (_request == null) {
        _request = open_rtb.BidRequest.avro(get().request);
      }
      return _request;
    }

    @Override public boolean isDefaultRequest() {
      if (is_default$request == null) {
        is_default$request = getRequest().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Avro._DEFAULT.get().getRequest().get());
      }
      return is_default$request;
    }

    @Override public open_rtb.BidResponse getResponse() {
      if (_response == null) {
        _response = open_rtb.BidResponse.avro(get().response);
      }
      return _response;
    }

    @Override public boolean isDefaultResponse() {
      if (is_default$response == null) {
        is_default$response = getResponse().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Avro._DEFAULT.get().getResponse().get());
      }
      return is_default$response;
    }

    @Override public java.util.SortedMap getProperties() {
      if (_properties == null) {
        _properties = java.util.Collections.unmodifiableSortedMap(get().properties.entrySet().stream().collect(java.util.stream.Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString(), (u,v) -> { throw new java.lang.IllegalStateException("Duplicate key " + u); }, () -> new java.util.TreeMap())));
      }
      return _properties;
    }

    @Override public boolean isDefaultProperties() {
      if (is_default$properties == null) {
        is_default$properties = getProperties().isEmpty();
      }
      return is_default$properties;
    }

    @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 com.adgear.anoa.test.ad_exchange.LogEventAvro decode(byte[] binaryEncoding) throws java.io.IOException {
      com.adgear.anoa.test.ad_exchange.LogEventAvro instance = new com.adgear.anoa.test.ad_exchange.LogEventAvro();
      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 com.adgear.anoa.test.ad_exchange.LogEvent 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(com.adgear.anoa.test.ad_exchange.LogEventAvro.newBuilder().build(), null); }
    };

    static public final long serialVersionUID = 6;
  }

  static class AvroBuilder implements Builder {

    final private com.adgear.anoa.test.ad_exchange.LogEventAvro.Builder builder;

    /** Only use this if you know what you are doing. */
    public AvroBuilder(com.adgear.anoa.test.ad_exchange.LogEventAvro.Builder builder) { this.builder = builder; }

    @Override public com.adgear.anoa.test.ad_exchange.LogEvent build() {
      return new Avro(builder.build(), null);
    }

    @Override public Builder setUuid(java.util.function.Supplier value) {
      builder.setUuid(java.nio.ByteBuffer.wrap(value.get().clone()));
      return this;
    }

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

    @Override public Builder setTimestamp(long value) {
      builder.setTimestamp(value);
      return this;
    }

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

    @Override public Builder setType(com.adgear.anoa.test.ad_exchange.LogEventType value) {
      builder.setType(com.adgear.anoa.test.ad_exchange.LogEventType.avro(value).get());
      return this;
    }

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

    @Override public Builder setRequest(open_rtb.BidRequest value) {
      builder.setRequest(open_rtb.BidRequest.avro(value).get());
      return this;
    }

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

    @Override public Builder setResponse(open_rtb.BidResponse value) {
      builder.setResponse(open_rtb.BidResponse.avro(value).get());
      return this;
    }

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

    @Override public Builder setProperties(java.util.Map value) {
      builder.setProperties(value.entrySet().stream().collect(java.util.stream.Collectors.toMap(e -> new org.apache.avro.util.Utf8(e.getKey()), e -> new org.apache.avro.util.Utf8(e.getValue()), (u,v) -> { throw new java.lang.IllegalStateException("Duplicate key " + u); }, () -> new java.util.HashMap<>(value.size()))));
      return this;
    }

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

  /** Returns new Avro builder instance with default values. */
  static Builder newAvroBuilder() {
    return new AvroBuilder(com.adgear.anoa.test.ad_exchange.LogEventAvro.newBuilder());
  }

  /** Returns new Avro builder instance based on existing prototype. */
  static Builder newAvroBuilder(com.adgear.anoa.test.ad_exchange.LogEventAvro other) {
    return new AvroBuilder(com.adgear.anoa.test.ad_exchange.LogEventAvro.newBuilder(other));
  }

  /** Returns new Avro builder instance based on existing prototype builder. */
  static Builder newAvroBuilder(com.adgear.anoa.test.ad_exchange.LogEventAvro.Builder other) {
    return new AvroBuilder(com.adgear.anoa.test.ad_exchange.LogEventAvro.newBuilder(other));
  }

  /** Returns new Avro builder instance based on existing prototype LogEvent. */
  static Builder newAvroBuilder(com.adgear.anoa.test.ad_exchange.LogEvent other) {
    return newAvroBuilder()
      .setUuid(other.getUuid())
      .setTimestamp(other.getTimestamp())
      .setType(other.getType())
      .setRequest(other.getRequest())
      .setResponse(other.getResponse())
      .setProperties(other.getProperties());
  }

  /** Returns a wrapped Avro record based on an instance of LogEvent. */
  static Avro avro(com.adgear.anoa.test.ad_exchange.LogEvent instance) {
    if (instance instanceof Avro) {
      return (Avro) instance;
    } else {
      return (Avro) newAvroBuilder(instance).build();
    }
  }

  /** Wraps an existing Avro record. */
  static Avro avro(com.adgear.anoa.test.ad_exchange.LogEventAvro wrapped) {
    assert wrapped != null;
    return new Avro(wrapped.freeze(), null);
  }

  /** Returns Avro record class. */
  static java.lang.Class getAvroClass() {
    return com.adgear.anoa.test.ad_exchange.LogEventAvro.class;
  }

  /** Returns Avro record schema. */
  static org.apache.avro.Schema getAvroSchema() {
    return com.adgear.anoa.test.ad_exchange.LogEventAvro.SCHEMA$;
  }

  static class Protobuf implements com.adgear.anoa.test.ad_exchange.LogEvent {

    private byte[] binaryEncoding;
    transient private com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent wrapped;
    transient private java.lang.Boolean is_default$uuid;
    transient private java.util.function.Supplier _uuid;
    transient private java.lang.Boolean is_default$timestamp;
    transient private java.lang.Boolean is_default$type;
    transient private com.adgear.anoa.test.ad_exchange.LogEventType _type;
    transient private java.lang.Boolean is_default$request;
    transient private open_rtb.BidRequest _request;
    transient private java.lang.Boolean is_default$response;
    transient private open_rtb.BidResponse _response;
    transient private java.lang.Boolean is_default$properties;
    transient private java.util.SortedMap _properties;

    private Protobuf(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent 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 com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent get() {
      if (wrapped == null) {
        try {
          wrapped = com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.parseFrom(binaryEncoding);
        } catch (java.io.IOException e) {
          throw new java.io.UncheckedIOException(e);
        }
      }
      return wrapped;
    }

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

    @Override public java.util.function.Supplier getUuid() {
      if (_uuid == null) {
        _uuid = () -> get().getUuid().toByteArray();
      }
      return _uuid;
    }

    @Override public boolean isDefaultUuid() {
      if (is_default$uuid == null) {
        is_default$uuid = java.util.Arrays.equals(getUuid().get(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes());
      }
      return is_default$uuid;
    }

    @Override public long getTimestamp() {
      return get().getTimestamp();
    }

    @Override public boolean isDefaultTimestamp() {
      if (is_default$timestamp == null) {
        is_default$timestamp = 0 == getTimestamp();
      }
      return is_default$timestamp;
    }

    @Override public com.adgear.anoa.test.ad_exchange.LogEventType getType() {
      if (_type == null) {
        _type = com.adgear.anoa.test.ad_exchange.LogEventType.protobuf(get().getType());
      }
      return _type;
    }

    @Override public boolean isDefaultType() {
      if (is_default$type == null) {
        is_default$type = getType().getOrdinal() == 0;
      }
      return is_default$type;
    }

    @Override public open_rtb.BidRequest getRequest() {
      if (_request == null) {
        _request = open_rtb.BidRequest.protobuf(get().getRequest());
      }
      return _request;
    }

    @Override public boolean isDefaultRequest() {
      if (is_default$request == null) {
        is_default$request = getRequest().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Protobuf._DEFAULT.get().getRequest().get());
      }
      return is_default$request;
    }

    @Override public open_rtb.BidResponse getResponse() {
      if (_response == null) {
        _response = open_rtb.BidResponse.protobuf(get().getResponse());
      }
      return _response;
    }

    @Override public boolean isDefaultResponse() {
      if (is_default$response == null) {
        is_default$response = getResponse().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Protobuf._DEFAULT.get().getResponse().get());
      }
      return is_default$response;
    }

    @Override public java.util.SortedMap getProperties() {
      if (_properties == null) {
        _properties = java.util.Collections.unmodifiableSortedMap(get().getProperties().entrySet().stream().collect(java.util.stream.Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (u,v) -> { throw new java.lang.IllegalStateException("Duplicate key " + u); }, () -> new java.util.TreeMap())));
      }
      return _properties;
    }

    @Override public boolean isDefaultProperties() {
      if (is_default$properties == null) {
        is_default$properties = getProperties().isEmpty();
      }
      return is_default$properties;
    }

    @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 com.adgear.anoa.test.ad_exchange.LogEvent from(byte[] binaryEncoding) throws java.io.IOException {
      return new Protobuf(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.parseFrom(binaryEncoding), binaryEncoding);
    }

    static private java.lang.ThreadLocal _DEFAULT = new java.lang.ThreadLocal() {
      @Override protected Protobuf initialValue() { return new Protobuf(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.getDefaultInstance() , null); }
    };

    static public final long serialVersionUID = 6;
  }

  static class ProtobufBuilder implements Builder {

    final private com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.Builder builder;

    /** Only use this if you know what you are doing. */
    public ProtobufBuilder(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.Builder builder) { this.builder = builder; }

    @Override public com.adgear.anoa.test.ad_exchange.LogEvent build() {
      return new Protobuf(builder.build(), null);
    }

    @Override public Builder setUuid(java.util.function.Supplier value) {
      if (!(java.util.Arrays.equals(value.get(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes()))) {
        builder.setUuid(com.google.protobuf.ByteString.copyFrom(value.get()));
      }
      return this;
    }

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

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

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

    @Override public Builder setType(com.adgear.anoa.test.ad_exchange.LogEventType value) {
      if (!(value.getOrdinal() == 0)) {
        builder.setType(com.adgear.anoa.test.ad_exchange.LogEventType.protobuf(value).get());
      }
      return this;
    }

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

    @Override public Builder setRequest(open_rtb.BidRequest value) {
      if (!(value.get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Protobuf._DEFAULT.get().getRequest().get()))) {
        builder.setRequest(open_rtb.BidRequest.protobuf(value).get());
      }
      return this;
    }

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

    @Override public Builder setResponse(open_rtb.BidResponse value) {
      if (!(value.get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Protobuf._DEFAULT.get().getResponse().get()))) {
        builder.setResponse(open_rtb.BidResponse.protobuf(value).get());
      }
      return this;
    }

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

    @Override public Builder setProperties(java.util.Map value) {
      if (!(value.isEmpty())) {
        builder.putAllProperties(value.entrySet().stream().collect(java.util.stream.Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (u,v) -> { throw new java.lang.IllegalStateException("Duplicate key " + u); }, () -> new java.util.HashMap(value.size()))));
      }
      return this;
    }

    @Override public Builder clearProperties() {
      builder.putAllProperties(java.util.Collections.emptyMap());
      return this;
    }
  }

  /** Returns new Protobuf builder instance with default values. */
  static Builder newProtobufBuilder() {
    return new ProtobufBuilder(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.newBuilder());
  }

  /** Returns new Protobuf builder instance based on existing prototype. */
  static Builder newProtobufBuilder(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent other) {
    return new ProtobufBuilder(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.newBuilder(other));
  }

  /** Returns new Protobuf builder instance based on existing prototype LogEvent. */
  static Builder newProtobufBuilder(com.adgear.anoa.test.ad_exchange.LogEvent other) {
    return newProtobufBuilder()
      .setUuid(other.getUuid())
      .setTimestamp(other.getTimestamp())
      .setType(other.getType())
      .setRequest(other.getRequest())
      .setResponse(other.getResponse())
      .setProperties(other.getProperties());
  }

  /** Returns a wrapped Protobuf message based on an instance of LogEvent. */
  static Protobuf protobuf(com.adgear.anoa.test.ad_exchange.LogEvent instance) {
    if (instance instanceof Protobuf) {
      return (Protobuf) instance;
    }
    return (Protobuf) newProtobufBuilder(instance).build();
  }

  /** Wraps an existing Protobuf message. */
  static Protobuf protobuf(com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent wrapped) {
    assert wrapped != null;
    return new Protobuf(wrapped, null);
  }

  /** Returns Protobuf class for this struct. */
  static java.lang.Class getProtobufClass() {
    return com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.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 com.adgear.anoa.test.ad_exchange.AdExchangeProtobuf.LogEvent.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 com.adgear.anoa.test.ad_exchange.LogEvent {

    private com.adgear.anoa.test.ad_exchange.LogEventThrift wrapped;
    transient private java.lang.Boolean is_default$uuid;
    transient private java.util.function.Supplier _uuid;
    transient private java.lang.Boolean is_default$timestamp;
    transient private java.lang.Boolean is_default$type;
    transient private com.adgear.anoa.test.ad_exchange.LogEventType _type;
    transient private java.lang.Boolean is_default$request;
    transient private open_rtb.BidRequest _request;
    transient private java.lang.Boolean is_default$response;
    transient private open_rtb.BidResponse _response;
    transient private java.lang.Boolean is_default$properties;
    transient private java.util.SortedMap _properties;

    /** Wraps an existing instance. Only use this if you know what you are doing. */
    public Thrift(com.adgear.anoa.test.ad_exchange.LogEventThrift wrapped) { this.wrapped = wrapped; }

    /** Create a new wrapper. */
    public Thrift() { this(new com.adgear.anoa.test.ad_exchange.LogEventThrift()); }

    @Override public com.adgear.anoa.test.ad_exchange.LogEventThrift get() { return wrapped; }

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

    @Override public java.util.function.Supplier getUuid() {
      if (_uuid == null) {
        _uuid = java.util.Optional.ofNullable(wrapped.getUuid()).orElseGet(() -> new byte[0])::clone;
      }
      return _uuid;
    }

    @Override public boolean isDefaultUuid() {
      if (is_default$uuid == null) {
        is_default$uuid = java.util.Arrays.equals(getUuid().get(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes());
      }
      return is_default$uuid;
    }

    @Override public long getTimestamp() {
      return wrapped.getTimestamp();
    }

    @Override public boolean isDefaultTimestamp() {
      if (is_default$timestamp == null) {
        is_default$timestamp = 0 == getTimestamp();
      }
      return is_default$timestamp;
    }

    @Override public com.adgear.anoa.test.ad_exchange.LogEventType getType() {
      if (_type == null) {
        _type = com.adgear.anoa.test.ad_exchange.LogEventType.thrift(java.util.Optional.ofNullable(wrapped.getType()).map(org.apache.thrift.TEnum::getValue).orElse(0));
      }
      return _type;
    }

    @Override public boolean isDefaultType() {
      if (is_default$type == null) {
        is_default$type = getType().getOrdinal() == 0;
      }
      return is_default$type;
    }

    @Override public open_rtb.BidRequest getRequest() {
      if (_request == null) {
        _request = open_rtb.BidRequest.thrift(java.util.Optional.ofNullable(wrapped.getRequest()).orElseGet(open_rtb.BidRequestThrift::new));
      }
      return _request;
    }

    @Override public boolean isDefaultRequest() {
      if (is_default$request == null) {
        is_default$request = getRequest().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Thrift._DEFAULT.get().getRequest().get());
      }
      return is_default$request;
    }

    @Override public open_rtb.BidResponse getResponse() {
      if (_response == null) {
        _response = open_rtb.BidResponse.thrift(java.util.Optional.ofNullable(wrapped.getResponse()).orElseGet(open_rtb.BidResponseThrift::new));
      }
      return _response;
    }

    @Override public boolean isDefaultResponse() {
      if (is_default$response == null) {
        is_default$response = getResponse().get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Thrift._DEFAULT.get().getResponse().get());
      }
      return is_default$response;
    }

    @Override public java.util.SortedMap getProperties() {
      if (_properties == null) {
        _properties = java.util.Optional.ofNullable(wrapped.getProperties()).orElseGet(java.util.Collections::emptyMap).entrySet().stream().collect(java.util.stream.Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (u,v) -> { throw new java.lang.IllegalStateException("Duplicate key " + u); }, () -> new java.util.TreeMap()));
      }
      return _properties;
    }

    @Override public boolean isDefaultProperties() {
      if (is_default$properties == null) {
        is_default$properties = getProperties().isEmpty();
      }
      return is_default$properties;
    }

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

  static class ThriftBuilder implements Builder {

    final private com.adgear.anoa.test.ad_exchange.LogEventThrift builder;

    /** Only use this if you know what you are doing. */
    public ThriftBuilder(com.adgear.anoa.test.ad_exchange.LogEventThrift builder) { this.builder = builder; }

    @Override public com.adgear.anoa.test.ad_exchange.LogEvent build() {
      return new Thrift((com.adgear.anoa.test.ad_exchange.LogEventThrift) builder.deepCopy());
    }

    @Override public Builder setUuid(java.util.function.Supplier value) {
      if (!(java.util.Arrays.equals(value.get(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes()))) {
        builder.setUuid(java.nio.ByteBuffer.wrap(value.get().clone()));
      }
      return this;
    }

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

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

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

    @Override public Builder setType(com.adgear.anoa.test.ad_exchange.LogEventType value) {
      if (!(value.getOrdinal() == 0)) {
        builder.setType(com.adgear.anoa.test.ad_exchange.LogEventType.thrift(value).get());
      }
      return this;
    }

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

    @Override public Builder setRequest(open_rtb.BidRequest value) {
      if (!(value.get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Thrift._DEFAULT.get().getRequest().get()))) {
        builder.setRequest(open_rtb.BidRequest.thrift(value).get());
      }
      return this;
    }

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

    @Override public Builder setResponse(open_rtb.BidResponse value) {
      if (!(value.get().equals(com.adgear.anoa.test.ad_exchange.LogEvent.Thrift._DEFAULT.get().getResponse().get()))) {
        builder.setResponse(open_rtb.BidResponse.thrift(value).get());
      }
      return this;
    }

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

    @Override public Builder setProperties(java.util.Map value) {
      if (!(value.isEmpty())) {
        builder.setProperties(value.entrySet().stream().collect(java.util.stream.Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (u,v) -> {throw new java.lang.IllegalStateException("Duplicate key " + u); }, () -> new java.util.HashMap<>(value.size()))));
      }
      return this;
    }

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

  /** Returns new Thrift builder instance with default values. */
  static Builder newThriftBuilder() {
    return new ThriftBuilder(new com.adgear.anoa.test.ad_exchange.LogEventThrift());
  }

  /** Returns new Thrift builder instance based on existing prototype. */
  static Builder newThriftBuilder(com.adgear.anoa.test.ad_exchange.LogEventThrift other) {
    return new ThriftBuilder((com.adgear.anoa.test.ad_exchange.LogEventThrift) other.deepCopy());
  }

  /** Returns new Thrift builder instance based on existing prototype LogEvent. */
  static Builder newThriftBuilder(com.adgear.anoa.test.ad_exchange.LogEvent other) {
    return newThriftBuilder()
      .setUuid(other.getUuid())
      .setTimestamp(other.getTimestamp())
      .setType(other.getType())
      .setRequest(other.getRequest())
      .setResponse(other.getResponse())
      .setProperties(other.getProperties());
  }

  /** Returns a wrapped Thrift struct based on an instance of LogEvent. */
  static Thrift thrift(com.adgear.anoa.test.ad_exchange.LogEvent 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(com.adgear.anoa.test.ad_exchange.LogEventThrift instance) {
    return new Thrift((com.adgear.anoa.test.ad_exchange.LogEventThrift) instance.deepCopy());
  }

  /** Returns Thrift class for this struct. */
  static java.lang.Class getThriftClass() {
    return com.adgear.anoa.test.ad_exchange.LogEventThrift.class;
  }

  /** Returns Thrift metadata map for this struct. */
  static java.util.Map getThriftMetadataMap() {
    return com.adgear.anoa.test.ad_exchange.LogEventThrift.metaDataMap;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy