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

com.adgear.anoa.test.simple.Simple 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.simple;

public interface Simple
  extends java.util.function.Supplier,
          java.lang.Comparable>,
          java.io.Serializable {

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

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

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

  /** field #1 */
  long getFoo();

  boolean isDefaultFoo();

  /** field #2 */
  java.util.function.Supplier getBar();

  boolean isDefaultBar();

  /** field #3 */
  double getBaz();

  boolean isDefaultBaz();

  @Deprecated default double getBlab() { return getBaz(); }

  @Deprecated default boolean isDefaultBlab() { return isDefaultBaz(); }

  public interface Builder {

    Simple build();

    Builder setFoo(long value);

    Builder clearFoo();

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

    Builder clearBar();

    Builder setBaz(double value);

    Builder clearBaz();

    @Deprecated default Builder setBlab(double value) { return setBaz(value); }

    @Deprecated default Builder clearBlab() { return clearBaz(); }
  }


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

    @Override public int compare(com.adgear.anoa.test.simple.Simple a, com.adgear.anoa.test.simple.Simple b) {
      int _cmp;
      if (0 != (_cmp = compareFoo(a, b))) return _cmp;
      if (0 != (_cmp = compareBar(a, b))) return _cmp;
      if (0 != (_cmp = compareBaz(a, b))) return _cmp;
      return 0;
    }

    static private int compareFoo (com.adgear.anoa.test.simple.Simple a, com.adgear.anoa.test.simple.Simple b) {
      final java.lang.Long fa = a.getFoo();
      final java.lang.Long fb = b.getFoo();
      return java.lang.Long.compare(fa, fb);
    }

    static private int compareBar (com.adgear.anoa.test.simple.Simple a, com.adgear.anoa.test.simple.Simple b) {
      final java.util.function.Supplier fa = a.getBar();
      final java.util.function.Supplier fb = b.getBar();
      return java.nio.ByteBuffer.wrap(fa.get()).compareTo(java.nio.ByteBuffer.wrap(fb.get()));
    }

    static private int compareBaz (com.adgear.anoa.test.simple.Simple a, com.adgear.anoa.test.simple.Simple b) {
      final java.lang.Double fa = a.getBaz();
      final java.lang.Double fb = b.getBaz();
      return java.lang.Double.compare(fa, fb);
    }

    static private final Comparator INSTANCE = new Comparator();

    static public final long serialVersionUID = 3;
  }

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

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

  static class NativeImpl implements com.adgear.anoa.test.simple.Simple {

    transient private java.lang.String json;
    private long __foo;
    transient private java.lang.Boolean is_default$foo;
    private byte[] __bar;
    transient private java.lang.Boolean is_default$bar;
    transient private java.util.function.Supplier _bar;
    private double __baz;
    transient private java.lang.Boolean is_default$baz;

    private NativeImpl() {
      __foo = 0L;
      is_default$foo = java.lang.Boolean.TRUE;
      __bar = "".getBytes();
      is_default$bar = java.lang.Boolean.TRUE;
      __baz = 0x0.0p0;
      is_default$baz = java.lang.Boolean.TRUE;
      json = "{}";
    }

    private NativeImpl(NativeImpl other) {
      setFoo(other.getFoo());
      setBar(other.getBar());
      setBaz(other.getBaz());
      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 (!isDefaultFoo()) {
        sb.append((0 == sb.length()) ? "{\"foo\": " : ", \"foo\": ")
          .append(__foo);
      }
      if (!isDefaultBar()) {
        sb.append((0 == sb.length()) ? "{\"bar\": " : ", \"bar\": ")
          .append("\"" + java.util.Base64.getEncoder().encodeToString(__bar) + '\"');
      }
      if (!isDefaultBaz()) {
        sb.append((0 == sb.length()) ? "{\"baz\": " : ", \"baz\": ")
          .append(__baz);
      }
      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 long getFoo() {
      return __foo;
    }

    @Override public boolean isDefaultFoo() {
      if (null == is_default$foo) {
        is_default$foo = 0 == getFoo();
      }
      return is_default$foo;
    }

    private void setFoo(long value) {
      this.__foo = value;
      this.is_default$foo = null;
      this.json = null;
    }

    @Override public java.util.function.Supplier getBar() {
      if (null == _bar) {
        _bar = (java.util.function.Supplier) __bar::clone;
      }
      return _bar;
    }

    @Override public boolean isDefaultBar() {
      if (null == is_default$bar) {
        is_default$bar = getBar().get().length == 0;
      }
      return is_default$bar;
    }

    private void setBar(java.util.function.Supplier value) {
      this.__bar = value.get().clone();
      this.is_default$bar = null;
      this.json = null;
      this._bar = null;
    }

    @Override public double getBaz() {
      return __baz;
    }

    @Override public boolean isDefaultBaz() {
      if (null == is_default$baz) {
        is_default$baz = 0x0.0p0 == getBaz();
      }
      return is_default$baz;
    }

    private void setBaz(double value) {
      this.__baz = value;
      this.is_default$baz = null;
      this.json = null;
    }

    static class NativeImplBuilder implements Builder {

      private NativeImpl wrapped = new NativeImpl();

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

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

      @Override public Builder clearFoo() {
        wrapped.__foo = _DEFAULT.get().__foo;
        wrapped.is_default$foo = true;
        return this;
      }

      @Override public Builder setBar(java.util.function.Supplier value) {
        if (value.get().length == 0) {
          return clearBar();
        }
        wrapped.setBar(value);
        return this;
      }

      @Override public Builder clearBar() {
        wrapped.__bar = _DEFAULT.get().__bar;
        wrapped.is_default$bar = true;
        wrapped._bar = _DEFAULT.get()._bar;
        return this;
      }

      @Override public Builder setBaz(double value) {
        if (0x0.0p0 == value) {
          return clearBaz();
        }
        wrapped.setBaz(value);
        return this;
      }

      @Override public Builder clearBaz() {
        wrapped.__baz = _DEFAULT.get().__baz;
        wrapped.is_default$baz = 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 = 3;
  }

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

  /** Returns a POJO builder instance based on existing prototype Simple. */
  static Builder newNativeImplBuilder(com.adgear.anoa.test.simple.Simple other) {
    return newNativeImplBuilder()
      .setFoo(other.getFoo())
      .setBar(other.getBar())
      .setBaz(other.getBaz());
  }

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

  static class Avro implements com.adgear.anoa.test.simple.Simple {

    private byte[] binaryEncoding;
    transient private com.adgear.anoa.test.simple.SimpleAvro wrapped;
    transient private java.lang.Boolean is_default$foo;
    transient private java.lang.Boolean is_default$bar;
    transient private java.util.function.Supplier _bar;
    transient private java.lang.Boolean is_default$baz;

    private Avro(com.adgear.anoa.test.simple.SimpleAvro 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.simple.SimpleAvro 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 long getFoo() {
      return get().foo;
    }

    @Override public boolean isDefaultFoo() {
      if (is_default$foo == null) {
        is_default$foo = 0 == getFoo();
      }
      return is_default$foo;
    }

    @Override public java.util.function.Supplier getBar() {
      if (_bar == null) {
        _bar = java.util.Optional.of(get().bar).map(bb -> {byte[] b = new byte[bb.remaining()]; bb.asReadOnlyBuffer().get(b); return (java.util.function.Supplier)(b::clone);}).get();
      }
      return _bar;
    }

    @Override public boolean isDefaultBar() {
      if (is_default$bar == null) {
        is_default$bar = getBar().get().length == 0;
      }
      return is_default$bar;
    }

    @Override public double getBaz() {
      return get().baz;
    }

    @Override public boolean isDefaultBaz() {
      if (is_default$baz == null) {
        is_default$baz = 0x0.0p0 == getBaz();
      }
      return is_default$baz;
    }

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

    static public final long serialVersionUID = 3;
  }

  static class AvroBuilder implements Builder {

    final private com.adgear.anoa.test.simple.SimpleAvro.Builder builder;

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

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

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

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

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

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

    @Override public Builder setBaz(double value) {
      builder.setBaz(value);
      return this;
    }

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

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

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

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

  /** Returns new Avro builder instance based on existing prototype Simple. */
  static Builder newAvroBuilder(com.adgear.anoa.test.simple.Simple other) {
    return newAvroBuilder()
      .setFoo(other.getFoo())
      .setBar(other.getBar())
      .setBaz(other.getBaz());
  }

  /** Returns a wrapped Avro record based on an instance of Simple. */
  static Avro avro(com.adgear.anoa.test.simple.Simple 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.simple.SimpleAvro wrapped) {
    assert wrapped != null;
    return new Avro(wrapped.freeze(), null);
  }

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

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

  static class Protobuf implements com.adgear.anoa.test.simple.Simple {

    private byte[] binaryEncoding;
    transient private com.adgear.anoa.test.simple.SimpleProtobuf.Simple wrapped;
    transient private java.lang.Boolean is_default$foo;
    transient private java.lang.Boolean is_default$bar;
    transient private java.util.function.Supplier _bar;
    transient private java.lang.Boolean is_default$baz;

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

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

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

    @Override public boolean isDefaultFoo() {
      if (is_default$foo == null) {
        is_default$foo = 0 == getFoo();
      }
      return is_default$foo;
    }

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

    @Override public boolean isDefaultBar() {
      if (is_default$bar == null) {
        is_default$bar = getBar().get().length == 0;
      }
      return is_default$bar;
    }

    @Override public double getBaz() {
      return get().getBaz();
    }

    @Override public boolean isDefaultBaz() {
      if (is_default$baz == null) {
        is_default$baz = 0x0.0p0 == getBaz();
      }
      return is_default$baz;
    }

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

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

    static public final long serialVersionUID = 3;
  }

  static class ProtobufBuilder implements Builder {

    final private com.adgear.anoa.test.simple.SimpleProtobuf.Simple.Builder builder;

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

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

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

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

    @Override public Builder setBar(java.util.function.Supplier value) {
      if (!(value.get().length == 0)) {
        builder.setBar(com.google.protobuf.ByteString.copyFrom(value.get()));
      }
      return this;
    }

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

    @Override public Builder setBaz(double value) {
      if (!(0x0.0p0 == value)) {
        builder.setBaz(value);
      }
      return this;
    }

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

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

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

  /** Returns new Protobuf builder instance based on existing prototype Simple. */
  static Builder newProtobufBuilder(com.adgear.anoa.test.simple.Simple other) {
    return newProtobufBuilder()
      .setFoo(other.getFoo())
      .setBar(other.getBar())
      .setBaz(other.getBaz());
  }

  /** Returns a wrapped Protobuf message based on an instance of Simple. */
  static Protobuf protobuf(com.adgear.anoa.test.simple.Simple 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.simple.SimpleProtobuf.Simple 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.simple.SimpleProtobuf.Simple.class;
  }

  /** Returns Protobuf protocol class for this struct. */
  static java.lang.Class getProtobufProtocolClass() {
    return com.adgear.anoa.test.simple.SimpleProtobuf.class;
  }

  /** Returns Protobuf descriptor for this struct. */
  static com.google.protobuf.Descriptors.Descriptor getProtobufDescriptor() {
    return com.adgear.anoa.test.simple.SimpleProtobuf.Simple.getDescriptor();
  }

  /** Returns Protobuf protocol descriptor for this struct. */
  static com.google.protobuf.Descriptors.FileDescriptor getProtobufProtocolDescriptor() {
    return com.adgear.anoa.test.simple.SimpleProtobuf.getDescriptor();
  }

  static class Thrift implements com.adgear.anoa.test.simple.Simple {

    private com.adgear.anoa.test.simple.SimpleThrift wrapped;
    transient private java.lang.Boolean is_default$foo;
    transient private java.lang.Boolean is_default$bar;
    transient private java.util.function.Supplier _bar;
    transient private java.lang.Boolean is_default$baz;

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

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

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

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

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

    @Override public boolean isDefaultFoo() {
      if (is_default$foo == null) {
        is_default$foo = 0 == getFoo();
      }
      return is_default$foo;
    }

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

    @Override public boolean isDefaultBar() {
      if (is_default$bar == null) {
        is_default$bar = getBar().get().length == 0;
      }
      return is_default$bar;
    }

    @Override public double getBaz() {
      return wrapped.getBaz();
    }

    @Override public boolean isDefaultBaz() {
      if (is_default$baz == null) {
        is_default$baz = 0x0.0p0 == getBaz();
      }
      return is_default$baz;
    }

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

  static class ThriftBuilder implements Builder {

    final private com.adgear.anoa.test.simple.SimpleThrift builder;

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

    @Override public com.adgear.anoa.test.simple.Simple build() {
      return new Thrift((com.adgear.anoa.test.simple.SimpleThrift) builder.deepCopy());
    }

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

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

    @Override public Builder setBar(java.util.function.Supplier value) {
      if (!(value.get().length == 0)) {
        builder.setBar(java.nio.ByteBuffer.wrap(value.get().clone()));
      }
      return this;
    }

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

    @Override public Builder setBaz(double value) {
      if (!(0x0.0p0 == value)) {
        builder.setBaz(value);
      }
      return this;
    }

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

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

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

  /** Returns new Thrift builder instance based on existing prototype Simple. */
  static Builder newThriftBuilder(com.adgear.anoa.test.simple.Simple other) {
    return newThriftBuilder()
      .setFoo(other.getFoo())
      .setBar(other.getBar())
      .setBaz(other.getBaz());
  }

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy